@@ -118,12 +118,20 @@ def self.ssl_options(options)
118
118
else
119
119
raise ArgumentError , 'SSL client auth enabled but no client keypair specified'
120
120
end
121
- if result [ :pem ]
122
- result [ :pem_password ] = options [ :ssl_client_password ] if options [ :ssl_client_password ]
123
- # Make sure there's not a password required, or that if the password is given, it is correct.
124
- # We do not want to wait on STDIN.
125
- # This will raise OpenSSL::PKey::RSAError if the key needs a password.
126
- OpenSSL ::PKey ::RSA . new ( result [ :pem ] , result [ :pem_password ] || '' )
121
+
122
+ # Make sure there's not a password required, or that if the password is given, it is correct.
123
+ # This will raise OpenSSL::PKey::RSAError if the key needs a password.
124
+ if result [ :pem ] && options [ :ssl_client_password ]
125
+ result [ :pem_password ] = options [ :ssl_client_password ]
126
+ _trash = OpenSSL ::PKey ::RSA . new ( result [ :pem ] , result [ :pem_password ] )
127
+ elsif result [ :pem ]
128
+ # Ruby 2.4 requires a minimum password length of 4. If no password is needed for
129
+ # the certificate, the specified password here is effectively ignored.
130
+ # We do not want to wait on STDIN, so a password-protected certificate without a
131
+ # password will cause this to raise an error. There are two checks here, to exclude
132
+ # an edge case where somebody did actually put '1234' as their password.
133
+ _trash = OpenSSL ::PKey ::RSA . new ( result [ :pem ] , '1234' )
134
+ _trash = OpenSSL ::PKey ::RSA . new ( result [ :pem ] , '5678' )
127
135
end
128
136
end
129
137
0 commit comments