@@ -404,7 +404,15 @@ static bool php_openssl_x509_fingerprint_match(php_stream *stream, X509 *peer, c
404404 break ;
405405 }
406406
407- return method && php_openssl_x509_fingerprint_is_equal (peer , method , Z_STR_P (val ));
407+ if (UNEXPECTED (method == NULL )) {
408+ php_stream_warn (stream , AuthFailed , "peer_fingerprint length doesn't match a md5 or sha1 hash" );
409+ return false;
410+ }
411+ if (!php_openssl_x509_fingerprint_is_equal (peer , method , Z_STR_P (val ))) {
412+ php_stream_warn (stream , AuthFailed , "peer_fingerprint match failure" );
413+ return false;
414+ }
415+ return true;
408416 } else if (Z_TYPE_P (val ) == IS_ARRAY ) {
409417 zval * current ;
410418 zend_string * key ;
@@ -422,6 +430,7 @@ static bool php_openssl_x509_fingerprint_match(php_stream *stream, X509 *peer, c
422430 return false;
423431 }
424432 if (!php_openssl_x509_fingerprint_is_equal (peer , ZSTR_VAL (key ), Z_STR_P (current ))) {
433+ php_stream_warn (stream , AuthFailed , "peer_fingerprint match failure" );
425434 return false;
426435 }
427436 } ZEND_HASH_FOREACH_END ();
@@ -635,9 +644,6 @@ static zend_result php_openssl_apply_peer_verification_policy(SSL *ssl, X509 *pe
635644 if (must_verify_fingerprint ) {
636645 if (Z_TYPE_P (peer_fingerprint ) == IS_STRING || Z_TYPE_P (peer_fingerprint ) == IS_ARRAY ) {
637646 if (!php_openssl_x509_fingerprint_match (stream , peer , peer_fingerprint )) {
638- php_stream_warn (stream , AuthFailed ,
639- "peer_fingerprint match failure"
640- );
641647 return FAILURE ;
642648 }
643649 } else {
0 commit comments