aboutsummaryrefslogtreecommitdiff
path: root/sni.go
blob: cc73fb3e80050b15fe81175332d8d74051963d61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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)
}