File tree 1 file changed +22
-16
lines changed
1 file changed +22
-16
lines changed Original file line number Diff line number Diff line change @@ -85,27 +85,33 @@ def write(msg)
85
85
end # def write
86
86
end # class Client
87
87
88
+ private
89
+ def setup_ssl
90
+ require "openssl"
91
+
92
+ @ssl_context = OpenSSL ::SSL ::SSLContext . new
93
+ @ssl_context . cert = OpenSSL ::X509 ::Certificate . new ( File . read ( @ssl_cert ) )
94
+ @ssl_context . key = OpenSSL ::PKey ::RSA . new ( File . read ( @ssl_key ) , @ssl_key_passphrase )
95
+ if @ssl_verify
96
+ @cert_store = OpenSSL ::X509 ::Store . new
97
+ # Load the system default certificate path to the store
98
+ @cert_store . set_default_paths
99
+ if File . directory? ( @ssl_cacert )
100
+ @cert_store . add_path ( @ssl_cacert )
101
+ else
102
+ @cert_store . add_file ( @ssl_cacert )
103
+ end
104
+ @ssl_context . cert_store = @cert_store
105
+ @ssl_context . verify_mode = OpenSSL ::SSL ::VERIFY_PEER |OpenSSL ::SSL ::VERIFY_FAIL_IF_NO_PEER_CERT
106
+ end
107
+ end # def setup_ssl
108
+
88
109
public
89
110
def register
90
111
require "socket"
91
112
require "stud/try"
92
- require "openssl"
93
113
if @ssl_enable
94
- @ssl_context = OpenSSL ::SSL ::SSLContext . new
95
- @ssl_context . cert = OpenSSL ::X509 ::Certificate . new ( File . read ( @ssl_cert ) )
96
- @ssl_context . key = OpenSSL ::PKey ::RSA . new ( File . read ( @ssl_key ) , @ssl_key_passphrase )
97
- if @ssl_verify
98
- @cert_store = OpenSSL ::X509 ::Store . new
99
- # Load the system default certificate path to the store
100
- @cert_store . set_default_paths
101
- if File . directory? ( @ssl_cacert )
102
- @cert_store . add_path ( @ssl_cacert )
103
- else
104
- @cert_store . add_file ( @ssl_cacert )
105
- end
106
- @ssl_context . cert_store = @cert_store
107
- @ssl_context . verify_mode = OpenSSL ::SSL ::VERIFY_PEER |OpenSSL ::SSL ::VERIFY_FAIL_IF_NO_PEER_CERT
108
- end
114
+ setup_ssl
109
115
end # @ssl_enable
110
116
111
117
if server?
You can’t perform that action at this time.
0 commit comments