mirror of https://github.com/v2ray/v2ray-core
only try issuing new certificate when user provide custom CA
parent
048f0ee56e
commit
abee8bddf3
|
@ -58,6 +58,15 @@ func issueCertificate(rawCA *Certificate, domain string) (*tls.Certificate, erro
|
|||
return &cert, err
|
||||
}
|
||||
|
||||
func (c *Config) hasCustomCA() bool {
|
||||
for _, certificate := range c.Certificate {
|
||||
if certificate.Usage == Certificate_AUTHORITY_ISSUE {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (c *Config) GetTLSConfig(opts ...Option) *tls.Config {
|
||||
config := &tls.Config{
|
||||
ClientSessionCache: globalSessionCache,
|
||||
|
@ -74,6 +83,7 @@ func (c *Config) GetTLSConfig(opts ...Option) *tls.Config {
|
|||
config.InsecureSkipVerify = c.AllowInsecure
|
||||
config.Certificates = c.BuildCertificates()
|
||||
config.BuildNameToCertificate()
|
||||
if c.hasCustomCA() {
|
||||
config.GetCertificate = func(hello *tls.ClientHelloInfo) (*tls.Certificate, error) {
|
||||
domain := hello.ServerName
|
||||
certExpired := false
|
||||
|
@ -121,6 +131,8 @@ func (c *Config) GetTLSConfig(opts ...Option) *tls.Config {
|
|||
|
||||
return issuedCertificate, nil
|
||||
}
|
||||
}
|
||||
|
||||
if len(c.ServerName) > 0 {
|
||||
config.ServerName = c.ServerName
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue