MCPcopy Create free account
hub / github.com/apache/brpc / CheckCert

Function CheckCert

test/brpc_ssl_unittest.cpp:316–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

314}
315
316void CheckCert(const char* cname, const char* cert) {
317 const int port = 8613;
318 brpc::Channel channel;
319 brpc::ChannelOptions coptions;
320 coptions.mutable_ssl_options()->sni_name = cname;
321 ASSERT_EQ(0, channel.Init("127.0.0.1", port, &coptions));
322
323 SendMultipleRPC(&channel, 1);
324 // client has no access to the sending socket
325 std::vector<brpc::SocketId> ids;
326 brpc::SocketMapList(&ids);
327 ASSERT_EQ(1u, ids.size());
328 brpc::SocketUniquePtr sock;
329 ASSERT_EQ(0, brpc::Socket::Address(ids[0], &sock));
330
331 X509* x509 = sock->GetPeerCertificate();
332 ASSERT_TRUE(x509 != NULL);
333 std::vector<std::string> cnames;
334 brpc::ExtractHostnames(x509, &cnames);
335 ASSERT_EQ(cert, cnames[0]) << x509;
336}
337
338std::string GetRawPemString(const char* fname) {
339 butil::ScopedFILE fp(fname, "r");

Callers 1

TEST_FFunction · 0.85

Calls 7

SocketMapListFunction · 0.85
GetPeerCertificateMethod · 0.80
SendMultipleRPCFunction · 0.70
ExtractHostnamesFunction · 0.50
mutable_ssl_optionsMethod · 0.45
InitMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected