@@ -348,27 +348,27 @@ def test_verify_mode_server_cert
348348 empty_store = OpenSSL ::X509 ::Store . new
349349
350350 # Valid certificate, SSL_VERIFY_PEER
351+ ctx = OpenSSL ::SSL ::SSLContext . new
352+ ctx . verify_mode = OpenSSL ::SSL ::VERIFY_PEER
353+ ctx . cert_store = populated_store
351354 assert_nothing_raised {
352- ctx = OpenSSL ::SSL ::SSLContext . new
353- ctx . verify_mode = OpenSSL ::SSL ::VERIFY_PEER
354- ctx . cert_store = populated_store
355355 server_connect ( port , ctx ) { |ssl | ssl . puts ( "abc" ) ; ssl . gets }
356356 }
357357
358358 # Invalid certificate, SSL_VERIFY_NONE
359+ ctx = OpenSSL ::SSL ::SSLContext . new
360+ ctx . verify_mode = OpenSSL ::SSL ::VERIFY_NONE
361+ ctx . cert_store = empty_store
359362 assert_nothing_raised {
360- ctx = OpenSSL ::SSL ::SSLContext . new
361- ctx . verify_mode = OpenSSL ::SSL ::VERIFY_NONE
362- ctx . cert_store = empty_store
363363 server_connect ( port , ctx ) { |ssl | ssl . puts ( "abc" ) ; ssl . gets }
364364 }
365365
366366 # Invalid certificate, SSL_VERIFY_PEER
367- assert_handshake_error {
368- ctx = OpenSSL ::SSL ::SSLContext . new
369- ctx . verify_mode = OpenSSL :: SSL :: VERIFY_PEER
370- ctx . cert_store = empty_store
371- server_connect ( port , ctx ) { | ssl | ssl . puts ( "abc" ) ; ssl . gets }
367+ ctx = OpenSSL :: SSL :: SSLContext . new
368+ ctx . verify_mode = OpenSSL ::SSL ::VERIFY_PEER
369+ ctx . cert_store = empty_store
370+ assert_raise ( OpenSSL :: SSL :: SSLError ) {
371+ server_connect ( port , ctx )
372372 }
373373 }
374374 end
0 commit comments