pull/17664/head
Yihua Zhang 6 years ago
parent adfe2238ef
commit 09cd07cfa0
  1. 3
      src/core/tsi/ssl_transport_security.cc
  2. 6
      test/core/tsi/ssl_transport_security_test.cc

@ -621,7 +621,7 @@ static tsi_result x509_store_load_certs(X509_STORE* cert_store,
} }
ERR_clear_error(); ERR_clear_error();
if (!X509_STORE_add_cert(cert_store, root)) { if (!X509_STORE_add_cert(cert_store, root)) {
size_t error = ERR_get_error(); unsigned long error = ERR_get_error();
if (ERR_GET_LIB(error) != ERR_LIB_X509 || if (ERR_GET_LIB(error) != ERR_LIB_X509 ||
ERR_GET_REASON(error) != X509_R_CERT_ALREADY_IN_HASH_TABLE) { ERR_GET_REASON(error) != X509_R_CERT_ALREADY_IN_HASH_TABLE) {
gpr_log(GPR_ERROR, "Could not add root certificate to ssl context."); gpr_log(GPR_ERROR, "Could not add root certificate to ssl context.");
@ -632,7 +632,6 @@ static tsi_result x509_store_load_certs(X509_STORE* cert_store,
X509_free(root); X509_free(root);
num_roots++; num_roots++;
} }
if (num_roots == 0) { if (num_roots == 0) {
gpr_log(GPR_ERROR, "Could not load any root certificate."); gpr_log(GPR_ERROR, "Could not load any root certificate.");
result = TSI_INVALID_ARGUMENT; result = TSI_INVALID_ARGUMENT;

@ -777,7 +777,7 @@ void ssl_tsi_test_handshaker_factory_internals() {
} }
void ssl_tsi_test_duplicate_root_certificates() { void ssl_tsi_test_duplicate_root_certificates() {
const char* root_cert = load_file(SSL_TSI_TEST_CREDENTIALS_DIR, "ca.pem"); char* root_cert = load_file(SSL_TSI_TEST_CREDENTIALS_DIR, "ca.pem");
char* dup_root_cert = static_cast<char*>( char* dup_root_cert = static_cast<char*>(
gpr_zalloc(sizeof(char) * (strlen(root_cert) * 2 + 1))); gpr_zalloc(sizeof(char) * (strlen(root_cert) * 2 + 1)));
memcpy(dup_root_cert, root_cert, strlen(root_cert)); memcpy(dup_root_cert, root_cert, strlen(root_cert));
@ -787,8 +787,8 @@ void ssl_tsi_test_duplicate_root_certificates() {
GPR_ASSERT(root_store != nullptr); GPR_ASSERT(root_store != nullptr);
// Free memory. // Free memory.
tsi_ssl_root_certs_store_destroy(root_store); tsi_ssl_root_certs_store_destroy(root_store);
gpr_free((void*)root_cert); gpr_free(root_cert);
gpr_free((void*)dup_root_cert); gpr_free(dup_root_cert);
} }
int main(int argc, char** argv) { int main(int argc, char** argv) {

Loading…
Cancel
Save