Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/tlsx/clients/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ type Response struct {
Version string `json:"tls_version,omitempty"`
// Cipher is the cipher for the tls request
Cipher string `json:"cipher,omitempty"`
// KeyExchange is the negotiated key exchange/curve
KeyExchange string `json:"key_exchange,omitempty"`
// CertificateResponse is the leaf certificate embedded in json
*CertificateResponse `json:",inline"`
// TLSConnection is the client used for TLS connection
Expand Down
29 changes: 29 additions & 0 deletions pkg/tlsx/tls/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"crypto/tls"
"crypto/x509"
"errors"
"fmt"
"net"
"os"
"time"
Expand Down Expand Up @@ -142,6 +143,7 @@ func (c *Client) ConnectWithOptions(hostname, ip, port string, options clients.C
}
tlsVersion := versionToTLSVersionString[connectionState.Version]
tlsCipher := tls.CipherSuiteName(connectionState.CipherSuite)
tlsKeyExchange := curveIDToString(connectionState.CurveID)

leafCertificate := connectionState.PeerCertificates[0]
certificateChain := connectionState.PeerCertificates[1:]
Expand All @@ -160,6 +162,7 @@ func (c *Client) ConnectWithOptions(hostname, ip, port string, options clients.C
Port: port,
Version: tlsVersion,
Cipher: tlsCipher,
KeyExchange: tlsKeyExchange,
TLSConnection: "ctls",
CertificateResponse: clients.Convertx509toResponse(c.options, hostname, leafCertificate, c.options.Cert),
ServerName: config.ServerName,
Expand Down Expand Up @@ -298,3 +301,29 @@ func (c *Client) getConfig(hostname, ip, port string, options clients.ConnectOpt
}
return config, nil
}

// curveIDToString converts CurveID to a human-readable string
func curveIDToString(curveID tls.CurveID) string {
// Standard curve IDs from crypto/tls
switch curveID {
case 23:
return "CurveP256"
case 24:
return "CurveP384"
case 25:
return "CurveP521"
case 29:
return "X25519"
case 4588:
return "X25519MLKEM768"
case 0:
return "" // No curve negotiated
default:
// Try using the built-in String() method if available
// Otherwise return the numeric form
if curveID > 0 {
return fmt.Sprintf("CurveID(%d)", curveID)
}
return ""
}
}