| 314 | } |
| 315 | |
| 316 | void 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 | |
| 338 | std::string GetRawPemString(const char* fname) { |
| 339 | butil::ScopedFILE fp(fname, "r"); |
no test coverage detected