aboutsummaryrefslogtreecommitdiff
path: root/route.go
diff options
context:
space:
mode:
Diffstat (limited to 'route.go')
-rw-r--r--route.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/route.go b/route.go
index 5e1b806..83998fd 100644
--- a/route.go
+++ b/route.go
@@ -21,10 +21,17 @@ type route struct {
// GetCertificate returns certificate for SNI negotiation
func (r Route) GetCertificate(h *tls.ClientHelloInfo) (*tls.Certificate, error) {
- if route, ok := r[h.ServerName]; ok && route.Certificate != nil {
- return route.Certificate, nil
+ host := h.ServerName
+ if v, ok := r[host]; ok && v.Certificate != nil {
+ return v.Certificate, nil
}
- return nil, errors.New("no cert for " + h.ServerName)
+ // HACK search for certs with port speciefied
+ for k, v := range r {
+ if k[:len(host)] == host {
+ return v.Certificate, nil
+ }
+ }
+ return nil, errors.New("no cert for " + host)
}
// Save routes to persistent file