ssl_credentials_test.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2017 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
20 
21 #include <stdio.h>
22 #include <string.h>
23 
24 #include <grpc/grpc_security.h>
25 #include <grpc/support/alloc.h>
26 #include <grpc/support/log.h>
27 
31 
33  grpc_ssl_pem_key_cert_pair grpc_pairs[] = {{"private_key1", "cert_chain1"},
34  {"private_key2", "cert_chain2"},
35  {"private_key3", "cert_chain3"}};
36  const size_t num_pairs = 3;
37 
38  {
39  tsi_ssl_pem_key_cert_pair* tsi_pairs =
41  GPR_ASSERT(tsi_pairs == nullptr);
42  }
43 
44  {
45  tsi_ssl_pem_key_cert_pair* tsi_pairs =
46  grpc_convert_grpc_to_tsi_cert_pairs(grpc_pairs, num_pairs);
47 
48  GPR_ASSERT(tsi_pairs != nullptr);
49  for (size_t i = 0; i < num_pairs; i++) {
50  GPR_ASSERT(strncmp(grpc_pairs[i].private_key, tsi_pairs[i].private_key,
51  strlen(grpc_pairs[i].private_key)) == 0);
52  GPR_ASSERT(strncmp(grpc_pairs[i].cert_chain, tsi_pairs[i].cert_chain,
53  strlen(grpc_pairs[i].cert_chain)) == 0);
54  }
55 
56  grpc_tsi_ssl_pem_key_cert_pairs_destroy(tsi_pairs, num_pairs);
57  }
58 }
59 
60 int main(int argc, char** argv) {
62  grpc_init();
63 
65 
66  grpc_shutdown();
67  return 0;
68 }
log.h
generate.env
env
Definition: generate.py:37
tsi_ssl_pem_key_cert_pair
Definition: ssl_transport_security.h:101
string.h
grpc_security.h
ssl_transport_security.h
test_convert_grpc_to_tsi_cert_pairs
static void test_convert_grpc_to_tsi_cert_pairs()
Definition: ssl_credentials_test.cc:32
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
grpc_tsi_ssl_pem_key_cert_pairs_destroy
void grpc_tsi_ssl_pem_key_cert_pairs_destroy(tsi_ssl_pem_key_cert_pair *kp, size_t num_key_cert_pairs)
Definition: ssl_utils.cc:168
grpc_convert_grpc_to_tsi_cert_pairs
tsi_ssl_pem_key_cert_pair * grpc_convert_grpc_to_tsi_cert_pairs(const grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs, size_t num_key_cert_pairs)
Definition: ssl_credentials.cc:202
test_config.h
alloc.h
private_key
Definition: hrss.c:1885
grpc::testing::TestEnvironment
Definition: test/core/util/test_config.h:54
main
int main(int argc, char **argv)
Definition: ssl_credentials_test.cc:60
grpc_init
GRPCAPI void grpc_init(void)
Definition: init.cc:146
ssl_credentials.h
grpc_shutdown
GRPCAPI void grpc_shutdown(void)
Definition: init.cc:209
grpc_ssl_pem_key_cert_pair
Definition: grpc_security.h:173
ssl_utils.h
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:20