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