99 webApp.setOnConnect([webApp](SocketConnection* socketConnection) {
100 VLOG(1) <<
"OnConnect " << webApp.getConfig().getInstanceName();
102 VLOG(1) <<
" Local: " << socketConnection->getLocalAddress().toString();
103 VLOG(1) <<
" Peer: " << socketConnection->getRemoteAddress().toString();
115 webApp.setOnConnected([webApp](SocketConnection* socketConnection) {
116 VLOG(1) <<
"OnConnected " << webApp.getConfig().getInstanceName();
118 X509* server_cert = SSL_get_peer_certificate(socketConnection->getSSL());
119 if (server_cert !=
nullptr) {
120 long verifyErr = SSL_get_verify_result(socketConnection->getSSL());
122 VLOG(1) <<
"\tPeer certificate verifyErr = " + std::to_string(verifyErr) +
": " +
123 std::string(X509_verify_cert_error_string(verifyErr));
125 char* str = X509_NAME_oneline(X509_get_subject_name(server_cert),
nullptr, 0);
126 VLOG(1) <<
"\t Subject: " + std::string(str);
129 str = X509_NAME_oneline(X509_get_issuer_name(server_cert),
nullptr, 0);
130 VLOG(1) <<
"\t Issuer: " + std::string(str);
135 GENERAL_NAMES* subjectAltNames =
136 static_cast<GENERAL_NAMES*>(X509_get_ext_d2i(server_cert, NID_subject_alt_name,
nullptr,
nullptr));
138 int32_t altNameCount = OPENSSL_sk_num(
reinterpret_cast<
const OPENSSL_STACK*>(subjectAltNames));
140 VLOG(1) <<
"\t Subject alternative name count: " << altNameCount;
141 for (int32_t i = 0; i < altNameCount; ++i) {
142 GENERAL_NAME* generalName = sk_GENERAL_NAME_value(subjectAltNames, i);
144 if (generalName->type == GEN_URI) {
145 std::string subjectAltName =
146 std::string(
reinterpret_cast<
const char*>(ASN1_STRING_get0_data(generalName->d.uniformResourceIdentifier)),
147 static_cast<std::size_t>(ASN1_STRING_length(generalName->d.uniformResourceIdentifier)));
148 VLOG(1) <<
"\t SAN (URI): '" + subjectAltName;
149 }
else if (generalName->type == GEN_DNS) {
150 std::string subjectAltName =
151 std::string(
reinterpret_cast<
const char*>(ASN1_STRING_get0_data(generalName->d.dNSName)),
152 static_cast<std::size_t>(ASN1_STRING_length(generalName->d.dNSName)));
153 VLOG(1) <<
"\t SAN (DNS): '" + subjectAltName;
155 VLOG(1) <<
"\t SAN (Type): '" + std::to_string(generalName->type);
159 sk_GENERAL_NAME_pop_free(subjectAltNames, GENERAL_NAME_free);
161 X509_free(server_cert);
163 LOG(WARNING) <<
"\tPeer certificate: no certificate";
167 webApp.setOnDisconnect([webApp](SocketConnection* socketConnection) {
168 VLOG(1) <<
"OnDisconnect " << webApp.getConfig().getInstanceName();
170 VLOG(2) <<
" Local: " << socketConnection->getLocalAddress().toString(
false);
171 VLOG(2) <<
" Peer: " << socketConnection->getRemoteAddress().toString(
false);
173 VLOG(2) <<
" Online Since: " << socketConnection->getOnlineSince();
174 VLOG(2) <<
" Online Duration: " << socketConnection->getOnlineDuration();
176 VLOG(2) <<
" Total Queued: " << socketConnection->getTotalQueued();
177 VLOG(2) <<
" Total Sent: " << socketConnection->getTotalSent();
178 VLOG(2) <<
" Write Delta: " << socketConnection->getTotalQueued() - socketConnection->getTotalSent();
179 VLOG(2) <<
" Total Read: " << socketConnection->getTotalRead();
180 VLOG(2) <<
" Total Processed: " << socketConnection->getTotalProcessed();
181 VLOG(2) <<
" Read Delta: " << socketConnection->getTotalRead() - socketConnection->getTotalProcessed();