@@ -1672,18 +1672,18 @@ PHP_FUNCTION(openssl_x509_export)
1672
1672
}
1673
1673
/* }}} */
1674
1674
1675
- static int php_openssl_x509_fingerprint (X509 * peer , const char * method , int raw , char * * out , int * out_len )
1675
+ static int php_openssl_x509_fingerprint (X509 * peer , const char * method , zend_bool raw , char * * out , int * out_len )
1676
1676
{
1677
1677
unsigned char md [EVP_MAX_MD_SIZE ];
1678
1678
const EVP_MD * mdtype ;
1679
1679
int n ;
1680
1680
1681
1681
if (!(mdtype = EVP_get_digestbyname (method ))) {
1682
- php_error_docref (NULL TSRMLS_CC , E_WARNING , "`%s`: Unknown signature algorithm" , method );
1683
- return 0 ;
1682
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "Unknown signature algorithm ");
1683
+ return FAILURE ;
1684
1684
} else if (!X509_digest (peer , mdtype , md , & n )) {
1685
1685
php_error_docref (NULL TSRMLS_CC , E_ERROR , "Could not generate signature" );
1686
- return 0 ;
1686
+ return FAILURE ;
1687
1687
}
1688
1688
1689
1689
if (raw ) {
@@ -1696,7 +1696,7 @@ static int php_openssl_x509_fingerprint(X509 *peer, const char *method, int raw,
1696
1696
make_digest_ex (* out , md , n );
1697
1697
}
1698
1698
1699
- return 1 ;
1699
+ return SUCCESS ;
1700
1700
}
1701
1701
1702
1702
static int php_x509_fingerprint_cmp (X509 * peer , const char * method , const char * expected )
@@ -1705,20 +1705,20 @@ static int php_x509_fingerprint_cmp(X509 *peer, const char *method, const char *
1705
1705
int fingerprint_len ;
1706
1706
int result = -1 ;
1707
1707
1708
- if (php_openssl_x509_fingerprint (peer , method , 0 , & fingerprint , & fingerprint_len )) {
1708
+ if (php_openssl_x509_fingerprint (peer , method , 0 , & fingerprint , & fingerprint_len ) == SUCCESS ) {
1709
1709
result = strcmp (expected , fingerprint );
1710
1710
efree (fingerprint );
1711
1711
}
1712
1712
1713
1713
return result ;
1714
1714
}
1715
1715
1716
- static int php_x509_fingerprint_match (X509 * peer , zval * * val )
1716
+ static zend_bool php_x509_fingerprint_match (X509 * peer , zval * val )
1717
1717
{
1718
- if (Z_TYPE_PP (val ) == IS_STRING ) {
1718
+ if (Z_TYPE_P (val ) == IS_STRING ) {
1719
1719
const char * method = NULL ;
1720
1720
1721
- switch (Z_STRLEN_PP (val )) {
1721
+ switch (Z_STRLEN_P (val )) {
1722
1722
case 32 :
1723
1723
method = "md5" ;
1724
1724
break ;
@@ -1728,19 +1728,19 @@ static int php_x509_fingerprint_match(X509 *peer, zval **val)
1728
1728
break ;
1729
1729
}
1730
1730
1731
- return method && php_x509_fingerprint_cmp (peer , method , Z_STRVAL_PP (val )) == 0 ;
1732
- } else if (Z_TYPE_PP (val ) == IS_ARRAY ) {
1731
+ return method && php_x509_fingerprint_cmp (peer , method , Z_STRVAL_P (val )) == 0 ;
1732
+ } else if (Z_TYPE_P (val ) == IS_ARRAY ) {
1733
1733
HashPosition pos ;
1734
1734
zval * * current ;
1735
1735
char * key ;
1736
1736
uint key_len ;
1737
1737
ulong key_index ;
1738
1738
1739
- for (zend_hash_internal_pointer_reset_ex (Z_ARRVAL_PP (val ), & pos );
1740
- zend_hash_get_current_data_ex (Z_ARRVAL_PP (val ), (void * * )& current , & pos ) == SUCCESS ;
1741
- zend_hash_move_forward_ex (Z_ARRVAL_PP (val ), & pos )
1739
+ for (zend_hash_internal_pointer_reset_ex (Z_ARRVAL_P (val ), & pos );
1740
+ zend_hash_get_current_data_ex (Z_ARRVAL_P (val ), (void * * )& current , & pos ) == SUCCESS ;
1741
+ zend_hash_move_forward_ex (Z_ARRVAL_P (val ), & pos )
1742
1742
) {
1743
- int key_type = zend_hash_get_current_key_ex (Z_ARRVAL_PP (val ), & key , & key_len , & key_index , 0 , & pos );
1743
+ int key_type = zend_hash_get_current_key_ex (Z_ARRVAL_P (val ), & key , & key_len , & key_index , 0 , & pos );
1744
1744
1745
1745
if (key_type == HASH_KEY_IS_STRING
1746
1746
&& Z_TYPE_PP (current ) == IS_STRING
@@ -1776,7 +1776,7 @@ PHP_FUNCTION(openssl_x509_fingerprint)
1776
1776
RETURN_FALSE ;
1777
1777
}
1778
1778
1779
- if (php_openssl_x509_fingerprint (cert , method , raw_output , & fingerprint , & fingerprint_len )) {
1779
+ if (php_openssl_x509_fingerprint (cert , method , raw_output , & fingerprint , & fingerprint_len ) == SUCCESS ) {
1780
1780
RETVAL_STRINGL (fingerprint , fingerprint_len , 0 );
1781
1781
} else {
1782
1782
RETVAL_FALSE ;
@@ -4989,7 +4989,7 @@ int php_openssl_apply_verification_policy(SSL *ssl, X509 *peer, php_stream *stre
4989
4989
4990
4990
if (GET_VER_OPT ("peer_fingerprint" )) {
4991
4991
if (Z_TYPE_PP (val ) == IS_STRING || Z_TYPE_PP (val ) == IS_ARRAY ) {
4992
- if (!php_x509_fingerprint_match (peer , val )) {
4992
+ if (!php_x509_fingerprint_match (peer , * val )) {
4993
4993
php_error_docref (NULL TSRMLS_CC , E_WARNING , "Peer fingerprint doesn't match" );
4994
4994
return FAILURE ;
4995
4995
}
0 commit comments