@@ -117,6 +117,11 @@ DEFINE_int32(stirling_enable_mongodb_tracing,
117
117
gflags::Int32FromEnv (" PX_STIRLING_ENABLE_MONGODB_TRACING" ,
118
118
px::stirling::TraceMode::OnForNewerKernel),
119
119
"If true, stirling will trace and process MongoDB messages");
120
+ DEFINE_int32 (
121
+ stirling_enable_tls_tracing,
122
+ gflags::Int32FromEnv (" PX_STIRLING_ENABLE_TLS_TRACING" , px::stirling::TraceMode::Off),
123
+ "If true, stirling will trace and process TLS protocol (not the TLS payload) messages. Note: "
124
+ "this disables tracing the plaintext within encrypted connections until gh#2095 is addressed." );
120
125
DEFINE_bool(stirling_disable_golang_tls_tracing,
121
126
gflags::BoolFromEnv(" PX_STIRLING_DISABLE_GOLANG_TLS_TRACING" , false),
122
127
" If true , stirling will not trace TLS traffic for Go applications. This implies "
@@ -283,6 +288,10 @@ void SocketTraceConnector::InitProtocolTransferSpecs() {
283
288
kAMQPTableNum ,
284
289
{kRoleClient , kRoleServer },
285
290
TRANSFER_STREAM_PROTOCOL (amqp)}},
291
+ {kProtocolTLS , TransferSpec{FLAGS_stirling_enable_tls_tracing,
292
+ kTLSTableNum ,
293
+ {kRoleClient , kRoleServer },
294
+ TRANSFER_STREAM_PROTOCOL (tls)}},
286
295
{kProtocolUnknown , TransferSpec{/* trace_mode */ px::stirling::TraceMode::Off,
287
296
/* table_num */ static_cast <uint32_t >(-1 ),
288
297
/* trace_roles */ {},
@@ -491,6 +500,7 @@ Status SocketTraceConnector::InitBPF() {
491
500
absl::StrCat (" -DENABLE_NATS_TRACING=" , protocol_transfer_specs_[kProtocolNATS ].enabled ),
492
501
absl::StrCat (" -DENABLE_AMQP_TRACING=" , protocol_transfer_specs_[kProtocolAMQP ].enabled ),
493
502
absl::StrCat (" -DENABLE_MONGO_TRACING=" , protocol_transfer_specs_[kProtocolMongo ].enabled ),
503
+ absl::StrCat (" -DENABLE_TLS_TRACING=" , protocol_transfer_specs_[kProtocolTLS ].enabled ),
494
504
absl::StrCat (" -DBPF_LOOP_LIMIT=" , FLAGS_stirling_bpf_loop_limit),
495
505
absl::StrCat (" -DBPF_CHUNK_LIMIT=" , FLAGS_stirling_bpf_chunk_limit),
496
506
};
@@ -1686,6 +1696,35 @@ void SocketTraceConnector::AppendMessage(ConnectorContext* ctx, const ConnTracke
1686
1696
#endif
1687
1697
}
1688
1698
1699
+ template <>
1700
+ void SocketTraceConnector::AppendMessage (ConnectorContext* ctx, const ConnTracker& conn_tracker,
1701
+ protocols::tls::Record record, DataTable* data_table) {
1702
+ protocols::tls::Frame& req_message = record.req ;
1703
+ protocols::tls::Frame& resp_message = record.resp ;
1704
+
1705
+ md::UPID upid (ctx->GetASID (), conn_tracker.conn_id ().upid .pid ,
1706
+ conn_tracker.conn_id ().upid .start_time_ticks );
1707
+
1708
+ DataTable::RecordBuilder<&kTLSTable > r (data_table, resp_message.timestamp_ns );
1709
+ r.Append <r.ColIndex (" time_" )>(resp_message.timestamp_ns );
1710
+ r.Append <r.ColIndex (" upid" )>(upid.value ());
1711
+ // Note that there is a string copy here,
1712
+ // But std::move is not allowed because we re-use conn object.
1713
+ r.Append <r.ColIndex (" remote_addr" )>(conn_tracker.remote_endpoint ().AddrStr ());
1714
+ r.Append <r.ColIndex (" remote_port" )>(conn_tracker.remote_endpoint ().port ());
1715
+ r.Append <r.ColIndex (" local_addr" )>(conn_tracker.local_endpoint ().AddrStr ());
1716
+ r.Append <r.ColIndex (" local_port" )>(conn_tracker.local_endpoint ().port ());
1717
+ r.Append <r.ColIndex (" trace_role" )>(conn_tracker.role ());
1718
+ r.Append <r.ColIndex (" req_type" )>(static_cast <uint64_t >(req_message.content_type ));
1719
+ r.Append <r.ColIndex (" version" )>(static_cast <uint64_t >(req_message.legacy_version ));
1720
+ r.Append <r.ColIndex (" extensions" )>(ToJSONString (req_message.extensions ), kMaxHTTPHeadersBytes );
1721
+ r.Append <r.ColIndex (" latency" )>(
1722
+ CalculateLatency (req_message.timestamp_ns , resp_message.timestamp_ns ));
1723
+ #ifndef NDEBUG
1724
+ r.Append <r.ColIndex (" px_info_" )>(PXInfoString (conn_tracker, record));
1725
+ #endif
1726
+ }
1727
+
1689
1728
void SocketTraceConnector::SetupOutput (const std::filesystem::path& path) {
1690
1729
DCHECK (!path.empty ());
1691
1730
0 commit comments