MCPcopy
hub / github.com/grpc/grpc-go / SPIFFEIDFromState

Function SPIFFEIDFromState

experimental/credentials/internal/spiffe.go:36–41  ·  view source on GitHub ↗

SPIFFEIDFromState parses the SPIFFE ID from State. If the SPIFFE ID format is invalid, return nil with warning.

(state tls.ConnectionState)

Source from the content-addressed store, hash-verified

34// SPIFFEIDFromState parses the SPIFFE ID from State. If the SPIFFE ID format
35// is invalid, return nil with warning.
36func SPIFFEIDFromState(state tls.ConnectionState) *url.URL {
37 if len(state.PeerCertificates) == 0 || len(state.PeerCertificates[0].URIs) == 0 {
38 return nil
39 }
40 return SPIFFEIDFromCert(state.PeerCertificates[0])
41}
42
43// SPIFFEIDFromCert parses the SPIFFE ID from x509.Certificate. If the SPIFFE
44// ID format is invalid, return nil with warning.

Callers 3

ClientHandshakeMethod · 0.92
ServerHandshakeMethod · 0.92
TestSPIFFEIDFromStateMethod · 0.70

Calls 1

SPIFFEIDFromCertFunction · 0.70

Tested by 1

TestSPIFFEIDFromStateMethod · 0.56