| | 52 | |
|---|
| | 53 | # Configure the SSL context |
|---|
| | 54 | # TODO: Allow the user to specify the verify mode and callback |
|---|
| | 55 | # Valid modes: |
|---|
| | 56 | # VERIFY_CLIENT_ONCE |
|---|
| | 57 | # VERIFY_FAIL_IF_NO_PEER_CERT |
|---|
| | 58 | # VERIFY_NONE |
|---|
| | 59 | # VERIFY_PEER |
|---|
| | 60 | self.sslctx.verify_mode = OpenSSL::SSL::VERIFY_PEER |
|---|
| | 61 | self.sslctx.options = OpenSSL::SSL::OP_ALL |
|---|
| | 62 | |
|---|
| | 63 | # Set the verification callback |
|---|
| | 64 | self.sslctx.verify_callback = Proc.new do |valid, store| |
|---|
| | 65 | self.peer_verified = valid |
|---|
| | 66 | true |
|---|
| | 67 | end |
|---|
| | 68 | |
|---|
| | 69 | # Tie the context to a socket |
|---|
| | 113 | # |
|---|
| | 114 | # Ignore shutdown requests |
|---|
| | 115 | # |
|---|
| | 116 | def shutdown(how=0) |
|---|
| | 117 | # Calling shutdown() on an SSL socket can lead to bad things |
|---|
| | 118 | # Cause of http://metasploit.com/dev/trac/ticket/102 |
|---|
| | 119 | end |
|---|
| | 120 | |
|---|
| | 121 | # |
|---|
| | 122 | # Access to peer cert |
|---|
| | 123 | # |
|---|
| | 124 | def peer_cert |
|---|
| | 125 | sslsock.peer_cert if sslsock |
|---|
| | 126 | end |
|---|
| | 127 | |
|---|
| | 128 | # |
|---|
| | 129 | # Access to peer cert chain |
|---|
| | 130 | # |
|---|
| | 131 | def peer_cert_chain |
|---|
| | 132 | sslsock.peer_cert_chain if sslsock |
|---|
| | 133 | end |
|---|
| | 134 | |
|---|
| | 135 | # |
|---|
| | 136 | # Access to the current cipher |
|---|
| | 137 | # |
|---|
| | 138 | def cipher |
|---|
| | 139 | sslsock.cipher if sslsock |
|---|
| | 140 | end |
|---|
| | 141 | |
|---|
| | 142 | |
|---|
| | 143 | |
|---|
| | 144 | attr_reader :peer_verified # :nodoc: |
|---|