Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify DNS SANs if PermittedDNSDomains is set #3982

Merged
merged 13 commits into from
Feb 16, 2018
Merged
27 changes: 22 additions & 5 deletions builtin/credential/cert/path_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,12 +439,29 @@ func validateConnState(roots *x509.CertPool, cs *tls.ConnectionState) ([][]*x509
}
}

chains, err := certs[0].Verify(opts)
if err != nil {
if _, ok := err.(x509.UnknownAuthorityError); ok {
return nil, nil
var chains [][]*x509.Certificate
var err error
switch {
case len(certs[0].DNSNames) > 0:
for _, dnsName := range certs[0].DNSNames {
opts.DNSName = dnsName
chains, err = certs[0].Verify(opts)
if err != nil {
if _, ok := err.(x509.UnknownAuthorityError); ok {
return nil, nil
}
return nil, errors.New("failed to verify client's certificate: " + err.Error())
}
}
default:
chains, err = certs[0].Verify(opts)
if err != nil {
if _, ok := err.(x509.UnknownAuthorityError); ok {
return nil, nil
}
return nil, errors.New("failed to verify client's certificate: " + err.Error())
}
return nil, errors.New("failed to verify client's certificate: " + err.Error())
}

return chains, nil
}
6 changes: 5 additions & 1 deletion website/source/api/auth/cert/index.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,11 @@ $ curl \
## Login with TLS Certificate Method

Log in and fetch a token. If there is a valid chain to a CA configured in the
method and all role constraints are matched, a token will be issued.
method and all role constraints are matched, a token will be issued. If the
certificate has DNS SANs in it, each of those will be verified. If Common Name
is required to be verified, then it should be a fully qualified DNS domain name
and must be duplicated as a DNS SAN (see
https://tools.ietf.org/html/rfc6125#section-2.3)

| Method | Path | Produces |
| :------- | :--------------------------- | :--------------------- |
Expand Down