aboutsummaryrefslogtreecommitdiff
path: root/sni.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-03-31 11:28:15 +0200
committerDimitri Sokolyuk <demon@dim13.org>2016-03-31 11:28:15 +0200
commit94899ddaf95e79324de8bcdd70ca18ff834ec0be (patch)
tree6c3ade19899a77b4e28aee2d4f752164b6d3ae53 /sni.go
parent647ff6e872fe9e1de936521acdb23373a610e68d (diff)
Separated routes branch
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)
+}