Fix uninitialized access (random error message) in certificate verification
This commit is contained in:
parent
1aa89e25dd
commit
1ef41f4eb6
1 changed files with 10 additions and 6 deletions
|
@ -389,13 +389,17 @@ ssl_locking_callback(int mode, int n, const char *file, int line)
|
||||||
{
|
{
|
||||||
unsigned long ret;
|
unsigned long ret;
|
||||||
|
|
||||||
if ((SSL_get_peer_certificate(ssl) == NULL) ||
|
if (SSL_get_peer_certificate(ssl) != NULL) {
|
||||||
((ret = SSL_get_verify_result(ssl)) != X509_V_OK)) {
|
if ((ret = SSL_get_verify_result(ssl)) != X509_V_OK) {
|
||||||
const char *reason = X509_verify_cert_error_string(ret);
|
const char *tmp = X509_verify_cert_error_string(ret);
|
||||||
|
OFString *reason = [OFString stringWithUTF8String: tmp];
|
||||||
@throw [SSLInvalidCertificateException
|
@throw [SSLInvalidCertificateException
|
||||||
exceptionWithClass: [self class]
|
exceptionWithClass: [self class]
|
||||||
reason: [OFString
|
reason: reason];
|
||||||
stringWithUTF8String: reason]];
|
|
||||||
}
|
}
|
||||||
|
} else
|
||||||
|
@throw [SSLInvalidCertificateException
|
||||||
|
exceptionWithClass: [self class]
|
||||||
|
reason: @"No certificate"];
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
Reference in a new issue