99 const std::string& instanceName = webApp.getConfig().getInstanceName();
101 webApp.setOnConnect([instanceName](SocketConnection* socketConnection) {
102 VLOG(1) <<
"OnConnect " << instanceName;
104 VLOG(1) <<
" Local: " << socketConnection->getLocalAddress().toString();
105 VLOG(1) <<
" Peer: " << socketConnection->getRemoteAddress().toString();
117 webApp.setOnConnected([instanceName](SocketConnection* socketConnection) {
118 VLOG(1) <<
"OnConnected " << instanceName;
120 X509* server_cert = SSL_get_peer_certificate(socketConnection->getSSL());
121 if (server_cert !=
nullptr) {
122 long verifyErr = SSL_get_verify_result(socketConnection->getSSL());
124 VLOG(1) <<
"\tPeer certificate verifyErr = " + std::to_string(verifyErr) +
": " +
125 std::string(X509_verify_cert_error_string(verifyErr));
127 char* str = X509_NAME_oneline(X509_get_subject_name(server_cert),
nullptr, 0);
128 VLOG(1) <<
"\t Subject: " + std::string(str);
131 str = X509_NAME_oneline(X509_get_issuer_name(server_cert),
nullptr, 0);
132 VLOG(1) <<
"\t Issuer: " + std::string(str);
137 GENERAL_NAMES* subjectAltNames =
138 static_cast<GENERAL_NAMES*>(X509_get_ext_d2i(server_cert, NID_subject_alt_name,
nullptr,
nullptr));
140 int32_t altNameCount = OPENSSL_sk_num(
reinterpret_cast<
const OPENSSL_STACK*>(subjectAltNames));
142 VLOG(1) <<
"\t Subject alternative name count: " << altNameCount;
143 for (int32_t i = 0; i < altNameCount; ++i) {
144 GENERAL_NAME* generalName = sk_GENERAL_NAME_value(subjectAltNames, i);
146 if (generalName->type == GEN_URI) {
147 std::string subjectAltName =
148 std::string(
reinterpret_cast<
const char*>(ASN1_STRING_get0_data(generalName->d.uniformResourceIdentifier)),
149 static_cast<std::size_t>(ASN1_STRING_length(generalName->d.uniformResourceIdentifier)));
150 VLOG(1) <<
"\t SAN (URI): '" + subjectAltName;
151 }
else if (generalName->type == GEN_DNS) {
152 std::string subjectAltName =
153 std::string(
reinterpret_cast<
const char*>(ASN1_STRING_get0_data(generalName->d.dNSName)),
154 static_cast<std::size_t>(ASN1_STRING_length(generalName->d.dNSName)));
155 VLOG(1) <<
"\t SAN (DNS): '" + subjectAltName;
157 VLOG(1) <<
"\t SAN (Type): '" + std::to_string(generalName->type);
161 sk_GENERAL_NAME_pop_free(subjectAltNames, GENERAL_NAME_free);
163 X509_free(server_cert);
165 LOG(WARNING) <<
"\tPeer certificate: no certificate";
169 webApp.setOnDisconnect([instanceName](SocketConnection* socketConnection) {
170 VLOG(1) <<
"OnDisconnect " << instanceName;
172 VLOG(2) <<
" Local: " << socketConnection->getLocalAddress().toString(
false);
173 VLOG(2) <<
" Peer: " << socketConnection->getRemoteAddress().toString(
false);
175 VLOG(2) <<
" Online Since: " << socketConnection->getOnlineSince();
176 VLOG(2) <<
" Online Duration: " << socketConnection->getOnlineDuration();
178 VLOG(2) <<
" Total Queued: " << socketConnection->getTotalQueued();
179 VLOG(2) <<
" Total Sent: " << socketConnection->getTotalSent();
180 VLOG(2) <<
" Write Delta: " << socketConnection->getTotalQueued() - socketConnection->getTotalSent();
181 VLOG(2) <<
" Total Read: " << socketConnection->getTotalRead();
182 VLOG(2) <<
" Total Processed: " << socketConnection->getTotalProcessed();
183 VLOG(2) <<
" Read Delta: " << socketConnection->getTotalRead() - socketConnection->getTotalProcessed();