| Index: runtime/bin/security_context.cc
|
| diff --git a/runtime/bin/security_context.cc b/runtime/bin/security_context.cc
|
| index 597f6c151713f80779589e5cfd8df508fa38285e..f394c3bb664b94c71070fb43d724ce1dd03e42ef 100644
|
| --- a/runtime/bin/security_context.cc
|
| +++ b/runtime/bin/security_context.cc
|
| @@ -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");
|
| }
|
|
|