aboutsummaryrefslogtreecommitdiff
path: root/sni.go
diff options
context:
space:
mode:
Diffstat (limited to 'sni.go')
-rw-r--r--sni.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/sni.go b/sni.go
new file mode 100644
index 0000000..cc73fb3
--- /dev/null
+++ b/sni.go
@@ -0,0 +1,17 @@
+package goxy
+
+import (
+ "crypto/tls"
+ "errors"
+)
+
+// SNI holds Certificates for Server Name Identication
+type SNI map[string]*tls.Certificate
+
+// GetCertificate returns certificate for SNI negotiation
+func (s SNI) GetCertificate(h *tls.ClientHelloInfo) (*tls.Certificate, error) {
+ if crt, ok := s[h.ServerName]; ok {
+ return crt, nil
+ }
+ return nil, errors.New("no cert for " + h.ServerName)
+}