Skip to content

Commit ca7c225

Browse files
committed
[tls] TLSSession now provides more info for pjs
1 parent 9db0480 commit ca7c225

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

src/filters/tls.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,46 @@ auto TLSSession::peer() -> crypto::Certificate* {
532532
return m_peer;
533533
}
534534

535+
auto TLSSession::cipher_name() -> std::string {
536+
return SSL_get_cipher_name(m_ssl);
537+
}
538+
539+
auto TLSSession::cipher_version() -> std::string {
540+
return SSL_get_cipher_version(m_ssl);
541+
}
542+
543+
auto TLSSession::cipher_bits() -> int {
544+
return SSL_get_cipher_bits(m_ssl, nullptr);
545+
}
546+
547+
auto TLSSession::negotiated_group() -> std::string {
548+
return SSL_group_to_name(m_ssl, SSL_get_negotiated_group(m_ssl));
549+
}
550+
551+
auto TLSSession::signature() -> std::string {
552+
int nid;
553+
SSL_get_signature_nid(m_ssl, &nid);
554+
return OBJ_nid2sn(nid);
555+
}
556+
557+
auto TLSSession::signature_type() -> std::string {
558+
int nid;
559+
SSL_get_signature_type_nid(m_ssl, &nid);
560+
return OBJ_nid2sn(nid);
561+
}
562+
563+
auto TLSSession::peer_signature() -> std::string {
564+
int nid;
565+
SSL_get_peer_signature_nid(m_ssl, &nid);
566+
return OBJ_nid2sn(nid);
567+
}
568+
569+
auto TLSSession::peer_signature_type() -> std::string {
570+
int nid;
571+
SSL_get_peer_signature_type_nid(m_ssl, &nid);
572+
return OBJ_nid2sn(nid);
573+
}
574+
535575
void TLSSession::on_input(Event *evt) {
536576
if (m_closed_input) return;
537577

@@ -1428,6 +1468,14 @@ template<> void ClassDef<TLSSession>::init() {
14281468
accessor("protocol", [](Object *obj, Value &ret) { ret.set(obj->as<TLSSession>()->protocol()); });
14291469
accessor("hostname", [](Object *obj, Value &ret) { ret.set(obj->as<TLSSession>()->hostname()); });
14301470
accessor("peer", [](Object *obj, Value &ret) { ret.set(obj->as<TLSSession>()->peer()); });
1471+
accessor("cipherName", [](Object *obj, Value &ret) { ret.set(obj->as<TLSSession>()->cipher_name()); });
1472+
accessor("cipherVersion", [](Object *obj, Value &ret) { ret.set(obj->as<TLSSession>()->cipher_version()); });
1473+
accessor("cipherBits", [](Object *obj, Value &ret) { ret.set(obj->as<TLSSession>()->cipher_bits()); });
1474+
accessor("negotiatedGroup", [](Object *obj, Value &ret) { ret.set(obj->as<TLSSession>()->negotiated_group()); });
1475+
accessor("signature", [](Object *obj, Value &ret) { ret.set(obj->as<TLSSession>()->signature()); });
1476+
accessor("signatureType", [](Object *obj, Value &ret) { ret.set(obj->as<TLSSession>()->signature_type()); });
1477+
accessor("peerSignature", [](Object *obj, Value &ret) { ret.set(obj->as<TLSSession>()->peer_signature()); });
1478+
accessor("peerSignatureType", [](Object *obj, Value &ret) { ret.set(obj->as<TLSSession>()->peer_signature_type()); });
14311479
}
14321480

14331481
} // namespace pjs

src/filters/tls.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@ class TLSSession :
172172
auto protocol() -> pjs::Str*;
173173
auto hostname() -> pjs::Str*;
174174
auto peer() -> crypto::Certificate*;
175+
auto cipher_name() -> std::string;
176+
auto cipher_version() -> std::string;
177+
auto cipher_bits() -> int;
178+
auto negotiated_group() -> std::string;
179+
auto signature() -> std::string;
180+
auto signature_type() -> std::string;
181+
auto peer_signature() -> std::string;
182+
auto peer_signature_type() -> std::string;
175183

176184
private:
177185
TLSSession(

0 commit comments

Comments
 (0)