-
Notifications
You must be signed in to change notification settings - Fork 7.8k
openssl: certificate fingerprinting support #464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Why is this making use of a by-reference out parameter? |
@nikic Updated to use return value as string or false. |
|
||
mdtype = EVP_get_digestbyname(method); | ||
if (!mdtype) { | ||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown signature algorithm"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't cert
be leaked here (and in the next error condition)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. I should really test with memory leaks reporting =S actually report_memleaks
is on by default, so maybe this just needs different reproduce code than what's already in the test suite.
make_digest_ex(*out, md, n); | ||
} | ||
|
||
return 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You use int (0/1) return value (I suspect instead of bool) here like in the other openssl patch. Whilt it seemed OK for a match() I don't like it here. We've got SUCCESS/FAILURE for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To add to that, parameters and return values that are boolean should be denoted as such, e.g. the raw
parameter here and the return value of match
should be zend_bool
. Furthermore I'd suggest to use minimal necessary amount of indirection, e.g. the zval **val
argument of match
could just as well be zval *val
unless I'm missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
On 4 Oct, 2013, at 5:29 PM, nikic notifications@github.com wrote:
In ext/openssl/openssl.c:
- } else if (!X509_digest(peer, mdtype, md, &n)) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not generate signature");
return 0;
- }
- if (raw) {
*out_len = n;
*out = estrndup(md, n);
- } else {
*out_len = n \* 2;
_out = emalloc(_out_len + 1);
make_digest_ex(*out, md, n);
- }
- return 1;
To add to that, parameters and return values that are boolean should be denoted as such, e.g. the raw parameter here and the return value of match should be zend_bool. Furthermore I'd suggest to use minimal necessary amount of indirection, e.g. the zval **val argument of match could just as well be zval *val unless I'm missing something.Thanks for reviewing the code, I'll make the changes when I'm hooked up to the "real" Internet again :)
—
Reply to this email directly or view it on GitHub.
Else... looks fine now. |
Using zend_bool for boolean arguments and return values Reduced one level of zval indirection where possible
Adds the function
openssl_x509_fingerprint()
to determine the fingerprint or hash of a certificate.Example:
Any hash functions that
openssl_digest()
supports can be used.It also comes with the
peer_fingerprint
connection assertion: