bssl pkcs12 shouldn't crash on missing key.

PKCS#12 files may not necessarily include keys.

Change-Id: Ibb43b609783b02aa9cbb192fea377081169666ff
Reviewed-on: https://boringssl-review.googlesource.com/6456
Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
David Benjamin 2015-11-07 18:32:39 -05:00 committed by Adam Langley
parent e348ff4a72
commit f606f9831b

View File

@ -128,8 +128,10 @@ bool DoPKCS12(const std::vector<std::string> &args) {
return false; return false;
} }
PEM_write_PrivateKey(stdout, key, NULL, NULL, 0, NULL, NULL); if (key != NULL) {
EVP_PKEY_free(key); PEM_write_PrivateKey(stdout, key, NULL, NULL, 0, NULL, NULL);
EVP_PKEY_free(key);
}
for (size_t i = 0; i < sk_X509_num(certs); i++) { for (size_t i = 0; i < sk_X509_num(certs); i++) {
PEM_write_X509(stdout, sk_X509_value(certs, i)); PEM_write_X509(stdout, sk_X509_value(certs, i));