Skip to content

Commit 136077d

Browse files
committed
PHPC-699: Rename "php_mongo" functions to not conflict with legacy driver
php_phongo_verify_hostname() can also be static, since it is not used outside of php_phongo.c
1 parent 05baae9 commit 136077d

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

php_phongo.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -983,13 +983,13 @@ ssize_t phongo_stream_poll (mongoc_stream_poll_t *streams, size_t nstreams, int3
983983
} /* }}} */
984984

985985
#if PHP_VERSION_ID < 50600
986-
int php_mongo_verify_hostname(const char *hostname, X509 *cert TSRMLS_DC)
986+
static int php_phongo_verify_hostname(const char *hostname, X509 *cert TSRMLS_DC)
987987
{
988-
if (php_mongo_matches_san_list(cert, hostname) == SUCCESS) {
988+
if (php_mongodb_matches_san_list(cert, hostname) == SUCCESS) {
989989
return SUCCESS;
990990
}
991991

992-
if (php_mongo_matches_common_name(cert, hostname TSRMLS_CC) == SUCCESS) {
992+
if (php_mongodb_matches_common_name(cert, hostname TSRMLS_CC) == SUCCESS) {
993993
return SUCCESS;
994994
}
995995

@@ -1012,7 +1012,7 @@ int php_phongo_peer_verify(php_stream *stream, X509 *cert, const char *hostname,
10121012
peer = hostname;
10131013
}
10141014

1015-
if (php_mongo_verify_hostname(peer, cert TSRMLS_CC) == FAILURE) {
1015+
if (php_phongo_verify_hostname(peer, cert TSRMLS_CC) == FAILURE) {
10161016
bson_set_error(error, MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_CONNECT, "Remote certificate SubjectAltName or CN does not match '%s'", hostname);
10171017
return false;
10181018
}
@@ -1068,8 +1068,8 @@ bool php_phongo_ssl_verify(php_stream *stream, const char *hostname, bson_error_
10681068
if (php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "ssl", "verify_expiry", &verify_expiry) == SUCCESS && zend_is_true(*verify_expiry)) {
10691069
#endif
10701070
time_t current = time(NULL);
1071-
time_t valid_from = php_mongo_asn1_time_to_time_t(X509_get_notBefore(cert) TSRMLS_CC);
1072-
time_t valid_until = php_mongo_asn1_time_to_time_t(X509_get_notAfter(cert) TSRMLS_CC);
1071+
time_t valid_from = php_mongodb_asn1_time_to_time_t(X509_get_notBefore(cert) TSRMLS_CC);
1072+
time_t valid_until = php_mongodb_asn1_time_to_time_t(X509_get_notAfter(cert) TSRMLS_CC);
10731073

10741074
if (valid_from > current) {
10751075
bson_set_error(error, MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_CONNECT, "Certificate is not valid yet on %s", hostname);

src/contrib/php-ssl.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#define timezone _timezone /* timezone is called _timezone in LibC */
3535
#endif
3636

37-
int php_mongo_matches_wildcard_name(const char *subjectname, const char *certname) /* {{{ */
37+
int php_mongodb_matches_wildcard_name(const char *subjectname, const char *certname) /* {{{ */
3838
{
3939
char *wildcard = NULL;
4040
int prefix_len, suffix_len, subject_len;
@@ -70,7 +70,7 @@ int php_mongo_matches_wildcard_name(const char *subjectname, const char *certnam
7070
}
7171
/* }}} */
7272

73-
int php_mongo_matches_san_list(X509 *peer, const char *subject_name) /* {{{ */
73+
int php_mongodb_matches_san_list(X509 *peer, const char *subject_name) /* {{{ */
7474
{
7575
int i, len;
7676
unsigned char *cert_name = NULL;
@@ -96,7 +96,7 @@ int php_mongo_matches_san_list(X509 *peer, const char *subject_name) /* {{{ */
9696
cert_name[len-1] = '\0';
9797
}
9898

99-
if (php_mongo_matches_wildcard_name(subject_name, (const char *)cert_name) == SUCCESS) {
99+
if (php_mongodb_matches_wildcard_name(subject_name, (const char *)cert_name) == SUCCESS) {
100100
OPENSSL_free(cert_name);
101101
return SUCCESS;
102102
}
@@ -124,7 +124,7 @@ int php_mongo_matches_san_list(X509 *peer, const char *subject_name) /* {{{ */
124124
}
125125
/* }}} */
126126

127-
int php_mongo_matches_common_name(X509 *peer, const char *subject_name TSRMLS_DC) /* {{{ */
127+
int php_mongodb_matches_common_name(X509 *peer, const char *subject_name TSRMLS_DC) /* {{{ */
128128
{
129129
char buf[1024];
130130
X509_NAME *cert_name;
@@ -137,7 +137,7 @@ int php_mongo_matches_common_name(X509 *peer, const char *subject_name TSRMLS_DC
137137
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to locate peer certificate CN");
138138
} else if ((size_t) cert_name_len != strlen(buf)) {
139139
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Peer certificate CN=`%.*s' is malformed", cert_name_len, buf);
140-
} else if (php_mongo_matches_wildcard_name(subject_name, buf) == SUCCESS) {
140+
} else if (php_mongodb_matches_wildcard_name(subject_name, buf) == SUCCESS) {
141141
return SUCCESS;
142142
} else {
143143
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Peer certificate CN=`%.*s' did not match expected CN=`%s'", cert_name_len, buf, subject_name);
@@ -147,7 +147,7 @@ int php_mongo_matches_common_name(X509 *peer, const char *subject_name TSRMLS_DC
147147
}
148148
/* }}} */
149149

150-
time_t php_mongo_asn1_time_to_time_t(ASN1_UTCTIME * timestr TSRMLS_DC) /* {{{ */
150+
time_t php_mongodb_asn1_time_to_time_t(ASN1_UTCTIME * timestr TSRMLS_DC) /* {{{ */
151151
{
152152
/*
153153
This is how the time string is formatted:

src/contrib/php-ssl.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
#include <openssl/x509.h>
3535
#include <openssl/x509v3.h>
3636

37-
int php_mongo_matches_wildcard_name(const char *subjectname, const char *certname);
38-
int php_mongo_matches_san_list(X509 *peer, const char *subject_name);
39-
int php_mongo_matches_common_name(X509 *peer, const char *subject_name TSRMLS_DC);
40-
time_t php_mongo_asn1_time_to_time_t(ASN1_UTCTIME * timestr TSRMLS_DC);
37+
int php_mongodb_matches_wildcard_name(const char *subjectname, const char *certname);
38+
int php_mongodb_matches_san_list(X509 *peer, const char *subject_name);
39+
int php_mongodb_matches_common_name(X509 *peer, const char *subject_name TSRMLS_DC);
40+
time_t php_mongodb_asn1_time_to_time_t(ASN1_UTCTIME * timestr TSRMLS_DC);
4141

4242
#endif /* HAVE_OPENSSL_EXT */
4343
#endif

0 commit comments

Comments
 (0)