@@ -718,56 +718,14 @@ static int php_openssl_win_cert_verify_callback(X509_STORE_CTX *x509_store_ctx,
718
718
LPWSTR server_name = NULL ;
719
719
BOOL verify_result ;
720
720
721
- { /* This looks ridiculous and it is - but we validate the name ourselves using the peer_name
722
- ctx option, so just use the CN from the cert here */
723
-
724
- X509_NAME * cert_name ;
725
- unsigned char * cert_name_utf8 ;
726
- int index , cert_name_utf8_len ;
727
- DWORD num_wchars ;
728
-
729
- cert_name = X509_get_subject_name (cert );
730
- index = X509_NAME_get_index_by_NID (cert_name , NID_commonName , -1 );
731
- if (index < 0 ) {
732
- php_error_docref (NULL , E_WARNING , "Unable to locate certificate CN" );
733
- CertFreeCertificateChain (cert_chain_ctx );
734
- CertFreeCertificateContext (cert_ctx );
735
- RETURN_CERT_VERIFY_FAILURE (SSL_R_CERTIFICATE_VERIFY_FAILED );
736
- }
737
-
738
- cert_name_utf8_len = PHP_X509_NAME_ENTRY_TO_UTF8 (cert_name , index , cert_name_utf8 );
739
-
740
- num_wchars = MultiByteToWideChar (CP_UTF8 , 0 , (char * )cert_name_utf8 , -1 , NULL , 0 );
741
- if (num_wchars == 0 ) {
742
- php_error_docref (NULL , E_WARNING , "Unable to convert %s to wide character string" , cert_name_utf8 );
743
- OPENSSL_free (cert_name_utf8 );
744
- CertFreeCertificateChain (cert_chain_ctx );
745
- CertFreeCertificateContext (cert_ctx );
746
- RETURN_CERT_VERIFY_FAILURE (SSL_R_CERTIFICATE_VERIFY_FAILED );
747
- }
748
-
749
- server_name = emalloc ((num_wchars * sizeof (WCHAR )) + sizeof (WCHAR ));
750
-
751
- num_wchars = MultiByteToWideChar (CP_UTF8 , 0 , (char * )cert_name_utf8 , -1 , server_name , num_wchars );
752
- if (num_wchars == 0 ) {
753
- php_error_docref (NULL , E_WARNING , "Unable to convert %s to wide character string" , cert_name_utf8 );
754
- efree (server_name );
755
- OPENSSL_free (cert_name_utf8 );
756
- CertFreeCertificateChain (cert_chain_ctx );
757
- CertFreeCertificateContext (cert_ctx );
758
- RETURN_CERT_VERIFY_FAILURE (SSL_R_CERTIFICATE_VERIFY_FAILED );
759
- }
760
-
761
- OPENSSL_free (cert_name_utf8 );
762
- }
763
-
764
721
ssl_policy_params .dwAuthType = (sslsock -> is_client ) ? AUTHTYPE_SERVER : AUTHTYPE_CLIENT ;
765
- ssl_policy_params .pwszServerName = server_name ;
722
+ /* we validate the name ourselves using the peer_name
723
+ ctx option, so no need to use a server name here */
724
+ ssl_policy_params .pwszServerName = NULL ;
766
725
chain_policy_params .pvExtraPolicyPara = & ssl_policy_params ;
767
726
768
727
verify_result = CertVerifyCertificateChainPolicy (CERT_CHAIN_POLICY_SSL , cert_chain_ctx , & chain_policy_params , & chain_policy_status );
769
728
770
- efree (server_name );
771
729
CertFreeCertificateChain (cert_chain_ctx );
772
730
CertFreeCertificateContext (cert_ctx );
773
731
0 commit comments