Skip to content

Commit

Permalink
Fixed gofmt concerns
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Jolly <[email protected]>
  • Loading branch information
djcode committed May 31, 2024
1 parent f71756a commit 2557e7f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions prober/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ func ProbeTCP(ctx context.Context, target string, module config.Module, registry
},
[]string{"fingerprint_sha256", "subject", "issuer", "subjectalternative"},
)

probeSSLLastKeyBits := prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "probe_ssl_last_chain_key_bits",
Help: "Contains SSL leaf certificate information",
Help: "Contains SSL leaf key information and size in bits",
},
[]string{"type", "fingerprint_sha256"},
)
Expand Down
18 changes: 9 additions & 9 deletions prober/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
package prober

import (
"crypto/ecdsa"
"crypto/rsa"
"crypto/sha256"
"crypto/tls"
"crypto/rsa"
"crypto/ecdsa"
"encoding/hex"
"strings"
"time"
Expand Down Expand Up @@ -92,17 +92,17 @@ func getTLSCipher(state *tls.ConnectionState) string {

func getTLSKeyTypeAndSize(state *tls.ConnectionState) (string, int) {
cert := state.PeerCertificates[0]
if key, ok := cert.PublicKey.(*ecdsa.PublicKey); ok {
return "ec", key.Curve.Params().BitSize
}
if key, ok := cert.PublicKey.(*rsa.PublicKey); ok {
return "rsa", key.N.BitLen()
}
if key, ok := cert.PublicKey.(*ecdsa.PublicKey); ok {
return "ec", key.Curve.Params().BitSize
}
if key, ok := cert.PublicKey.(*rsa.PublicKey); ok {
return "rsa", key.N.BitLen()
}
return "", 0
}

func getTLSKeyFingerprint(state *tls.ConnectionState) string {
cert := state.PeerCertificates[0]
fingerprint := sha256.Sum256(cert.RawSubjectPublicKeyInfo)
return hex.EncodeToString(fingerprint[:])
}
}

0 comments on commit 2557e7f

Please sign in to comment.