mirror of
https://github.com/TwiN/gatus.git
synced 2024-11-25 01:13:40 +01:00
Minor improvements
This commit is contained in:
parent
30cb7b6ec8
commit
bc25fea1c0
@ -63,24 +63,16 @@ func CanPerformStartTLS(address string, config *Config) (connected bool, certifi
|
|||||||
|
|
||||||
// CanPerformTLS checks whether a connection can be established to an address using the TLS protocol
|
// CanPerformTLS checks whether a connection can be established to an address using the TLS protocol
|
||||||
func CanPerformTLS(address string, config *Config) (connected bool, certificate *x509.Certificate, err error) {
|
func CanPerformTLS(address string, config *Config) (connected bool, certificate *x509.Certificate, err error) {
|
||||||
conn, err := tls.DialWithDialer(&net.Dialer{Timeout: config.Timeout}, "tcp", address, nil)
|
connection, err := tls.DialWithDialer(&net.Dialer{Timeout: config.Timeout}, "tcp", address, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer conn.Close()
|
defer connection.Close()
|
||||||
|
verifiedChains := connection.ConnectionState().VerifiedChains
|
||||||
verifiedChains := conn.ConnectionState().VerifiedChains
|
if len(verifiedChains) == 0 || len(verifiedChains[0]) == 0 {
|
||||||
if len(verifiedChains) == 0 {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
return true, verifiedChains[0][0], nil
|
||||||
chain := verifiedChains[0] // VerifiedChains[0] == PeerCertificates[0]
|
|
||||||
if len(chain) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
certificate = chain[0]
|
|
||||||
return true, certificate, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ping checks if an address can be pinged and returns the round-trip time if the address can be pinged
|
// Ping checks if an address can be pinged and returns the round-trip time if the address can be pinged
|
||||||
|
Loading…
Reference in New Issue
Block a user