certificate.Store: Check '*' scope last

This commit is contained in:
Adnan Maolood 2021-02-23 08:52:12 -05:00
parent 3c9c087a25
commit f6bccb156a

View File

@ -82,10 +82,6 @@ func (s *Store) Get(hostname string) (*tls.Certificate, error) {
s.mu.RLock()
defer s.mu.RUnlock()
cert, ok := s.certs[hostname]
if !ok {
// Try "*"
cert, ok = s.certs["*"]
}
if !ok {
// Try wildcard
wildcard := strings.SplitN(hostname, ".", 2)
@ -94,6 +90,10 @@ func (s *Store) Get(hostname string) (*tls.Certificate, error) {
cert, ok = s.certs[hostname]
}
}
if !ok {
// Try "*"
cert, ok = s.certs["*"]
}
if !ok {
return nil, errors.New("unrecognized scope")
}