|
|
|
@ -554,12 +554,12 @@ static tsi_result ssl_ctx_use_certificate_chain(SSL_CTX* context, |
|
|
|
|
X509* certificate = nullptr; |
|
|
|
|
BIO* pem; |
|
|
|
|
GPR_ASSERT(pem_cert_chain_size <= INT_MAX); |
|
|
|
|
pem = BIO_new_mem_buf((void*)pem_cert_chain, |
|
|
|
|
static_cast<int>(pem_cert_chain_size)); |
|
|
|
|
pem = BIO_new_mem_buf(pem_cert_chain, static_cast<int>(pem_cert_chain_size)); |
|
|
|
|
if (pem == nullptr) return TSI_OUT_OF_RESOURCES; |
|
|
|
|
|
|
|
|
|
do { |
|
|
|
|
certificate = PEM_read_bio_X509_AUX(pem, nullptr, nullptr, (void*)""); |
|
|
|
|
certificate = |
|
|
|
|
PEM_read_bio_X509_AUX(pem, nullptr, nullptr, const_cast<char*>("")); |
|
|
|
|
if (certificate == nullptr) { |
|
|
|
|
result = TSI_INVALID_ARGUMENT; |
|
|
|
|
break; |
|
|
|
@ -570,7 +570,7 @@ static tsi_result ssl_ctx_use_certificate_chain(SSL_CTX* context, |
|
|
|
|
} |
|
|
|
|
while (true) { |
|
|
|
|
X509* certificate_authority = |
|
|
|
|
PEM_read_bio_X509(pem, nullptr, nullptr, (void*)""); |
|
|
|
|
PEM_read_bio_X509(pem, nullptr, nullptr, const_cast<char*>("")); |
|
|
|
|
if (certificate_authority == nullptr) { |
|
|
|
|
ERR_clear_error(); |
|
|
|
|
break; /* Done reading. */ |
|
|
|
@ -674,10 +674,11 @@ static tsi_result ssl_ctx_use_pem_private_key(SSL_CTX* context, |
|
|
|
|
EVP_PKEY* private_key = nullptr; |
|
|
|
|
BIO* pem; |
|
|
|
|
GPR_ASSERT(pem_key_size <= INT_MAX); |
|
|
|
|
pem = BIO_new_mem_buf((void*)pem_key, static_cast<int>(pem_key_size)); |
|
|
|
|
pem = BIO_new_mem_buf(pem_key, static_cast<int>(pem_key_size)); |
|
|
|
|
if (pem == nullptr) return TSI_OUT_OF_RESOURCES; |
|
|
|
|
do { |
|
|
|
|
private_key = PEM_read_bio_PrivateKey(pem, nullptr, nullptr, (void*)""); |
|
|
|
|
private_key = |
|
|
|
|
PEM_read_bio_PrivateKey(pem, nullptr, nullptr, const_cast<char*>("")); |
|
|
|
|
if (private_key == nullptr) { |
|
|
|
|
result = TSI_INVALID_ARGUMENT; |
|
|
|
|
break; |
|
|
|
@ -718,7 +719,7 @@ static tsi_result x509_store_load_certs(X509_STORE* cert_store, |
|
|
|
|
X509_NAME* root_name = nullptr; |
|
|
|
|
BIO* pem; |
|
|
|
|
GPR_ASSERT(pem_roots_size <= INT_MAX); |
|
|
|
|
pem = BIO_new_mem_buf((void*)pem_roots, static_cast<int>(pem_roots_size)); |
|
|
|
|
pem = BIO_new_mem_buf(pem_roots, static_cast<int>(pem_roots_size)); |
|
|
|
|
if (cert_store == nullptr) return TSI_INVALID_ARGUMENT; |
|
|
|
|
if (pem == nullptr) return TSI_OUT_OF_RESOURCES; |
|
|
|
|
if (root_names != nullptr) { |
|
|
|
@ -727,7 +728,7 @@ static tsi_result x509_store_load_certs(X509_STORE* cert_store, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
while (true) { |
|
|
|
|
root = PEM_read_bio_X509_AUX(pem, nullptr, nullptr, (void*)""); |
|
|
|
|
root = PEM_read_bio_X509_AUX(pem, nullptr, nullptr, const_cast<char*>("")); |
|
|
|
|
if (root == nullptr) { |
|
|
|
|
ERR_clear_error(); |
|
|
|
|
break; /* We're at the end of stream. */ |
|
|
|
@ -837,10 +838,10 @@ tsi_result tsi_ssl_extract_x509_subject_names_from_pem_cert( |
|
|
|
|
tsi_result result = TSI_OK; |
|
|
|
|
X509* cert = nullptr; |
|
|
|
|
BIO* pem; |
|
|
|
|
pem = BIO_new_mem_buf((void*)pem_cert, static_cast<int>(strlen(pem_cert))); |
|
|
|
|
pem = BIO_new_mem_buf(pem_cert, static_cast<int>(strlen(pem_cert))); |
|
|
|
|
if (pem == nullptr) return TSI_OUT_OF_RESOURCES; |
|
|
|
|
|
|
|
|
|
cert = PEM_read_bio_X509(pem, nullptr, nullptr, (void*)""); |
|
|
|
|
cert = PEM_read_bio_X509(pem, nullptr, nullptr, const_cast<char*>("")); |
|
|
|
|
if (cert == nullptr) { |
|
|
|
|
gpr_log(GPR_ERROR, "Invalid certificate"); |
|
|
|
|
result = TSI_INVALID_ARGUMENT; |
|
|
|
|