mirror of
https://github.com/dart-lang/sdk
synced 2024-10-03 20:22:23 +00:00
Fixed memory leak in SetTrustedCertificates in SecurityContext
BUG= R=zra@google.com Review-Url: https://codereview.chromium.org/2923163004 .
This commit is contained in:
parent
b18c325f68
commit
0e164c043f
|
@ -228,20 +228,22 @@ static int SetTrustedCertificatesBytesPEM(SSL_CTX* context, BIO* bio) {
|
|||
|
||||
void SSLCertContext::SetTrustedCertificatesBytes(Dart_Handle cert_bytes,
|
||||
const char* password) {
|
||||
ScopedMemBIO bio(cert_bytes);
|
||||
int status = SetTrustedCertificatesBytesPEM(context(), bio.bio());
|
||||
if (status == 0) {
|
||||
if (SecureSocketUtils::NoPEMStartLine()) {
|
||||
int status = 0;
|
||||
{
|
||||
ScopedMemBIO bio(cert_bytes);
|
||||
status = SetTrustedCertificatesBytesPEM(context(), bio.bio());
|
||||
if (status == 0) {
|
||||
if (SecureSocketUtils::NoPEMStartLine()) {
|
||||
ERR_clear_error();
|
||||
BIO_reset(bio.bio());
|
||||
status =
|
||||
SetTrustedCertificatesBytesPKCS12(context(), bio.bio(), password);
|
||||
}
|
||||
} else {
|
||||
// The PEM file was successfully parsed.
|
||||
ERR_clear_error();
|
||||
BIO_reset(bio.bio());
|
||||
status =
|
||||
SetTrustedCertificatesBytesPKCS12(context(), bio.bio(), password);
|
||||
}
|
||||
} else {
|
||||
// The PEM file was successfully parsed.
|
||||
ERR_clear_error();
|
||||
}
|
||||
|
||||
SecureSocketUtils::CheckStatus(status, "TlsException",
|
||||
"Failure trusting builtin roots");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue