Skip to content

Commit f98576a

Browse files
authored
BUG/MEDIUM: Disable TLS verification from SPOE (#52)
Addtionnal TLS verification done in SPOE was causing problem as the haproxy fetch methods currently do not provide the full certificate chain. Since TLS verification was already enabled on haproxy side this just removes the additional verification done in SPOE. Fixes: #11
1 parent 6c47d09 commit f98576a

File tree

1 file changed

+18
-28
lines changed

1 file changed

+18
-28
lines changed

haproxy/spoe.go

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -42,39 +42,29 @@ func (h *SPOEHandler) Handler(args []spoe.Message) ([]spoe.Action, error) {
4242
return nil, errors.Wrap(err, "spoe handler")
4343
}
4444

45-
_, err = cert.Verify(x509.VerifyOptions{
46-
Roots: cfg.CAsPool,
47-
})
48-
if err != nil {
49-
log.Warnf("connect: error validating certificate: %s", err)
50-
}
51-
52-
authorized := err == nil
5345
sourceApp := ""
5446

55-
if authorized {
56-
certURI, err := connect.ParseCertURI(cert.URIs[0])
57-
if err != nil {
58-
log.Printf("connect: invalid leaf certificate URI")
59-
return nil, errors.New("connect: invalid leaf certificate URI")
60-
}
47+
certURI, err := connect.ParseCertURI(cert.URIs[0])
48+
if err != nil {
49+
log.Printf("connect: invalid leaf certificate URI")
50+
return nil, errors.New("connect: invalid leaf certificate URI")
51+
}
6152

62-
// Perform AuthZ
63-
resp, err := h.c.Agent().ConnectAuthorize(&api.AgentAuthorizeParams{
64-
Target: cfg.ServiceName,
65-
ClientCertURI: certURI.URI().String(),
66-
ClientCertSerial: connect.HexString(cert.SerialNumber.Bytes()),
67-
})
68-
if err != nil {
69-
return nil, errors.Wrap(err, "spoe handler: authz call failed")
70-
}
53+
// Perform AuthZ
54+
resp, err := h.c.Agent().ConnectAuthorize(&api.AgentAuthorizeParams{
55+
Target: cfg.ServiceName,
56+
ClientCertURI: certURI.URI().String(),
57+
ClientCertSerial: connect.HexString(cert.SerialNumber.Bytes()),
58+
})
59+
if err != nil {
60+
return nil, errors.Wrap(err, "spoe handler: authz call failed")
61+
}
7162

72-
log.Debugf("spoe: auth response from %s authorized=%v", certURI.URI().String(), resp.Authorized)
63+
log.Debugf("spoe: auth response from %s authorized=%v", certURI.URI().String(), resp.Authorized)
7364

74-
authorized = resp.Authorized
75-
if sis, ok := certURI.(*connect.SpiffeIDService); ok {
76-
sourceApp = sis.Service
77-
}
65+
authorized := resp.Authorized
66+
if sis, ok := certURI.(*connect.SpiffeIDService); ok {
67+
sourceApp = sis.Service
7868
}
7969

8070
res := 1

0 commit comments

Comments
 (0)