mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-15 16:48:41 +00:00
parent
347d9735da
commit
8b9c0ae593
7 changed files with 177 additions and 122 deletions
|
@ -59,10 +59,16 @@ func (c *Config) BuildCertificates() []*xtls.Certificate {
|
|||
continue
|
||||
}
|
||||
certs = append(certs, &keyPair)
|
||||
if entry.OcspStapling != 0 {
|
||||
if !entry.OneTimeLoading {
|
||||
var isOcspstapling bool
|
||||
hotRelodaInterval := uint64(3600)
|
||||
if entry.OcspStapling != 0 {
|
||||
hotRelodaInterval = entry.OcspStapling
|
||||
isOcspstapling = true
|
||||
}
|
||||
index := len(certs) - 1
|
||||
go func(cert *xtls.Certificate, index int) {
|
||||
t := time.NewTicker(time.Duration(entry.OcspStapling) * time.Second)
|
||||
t := time.NewTicker(time.Duration(hotRelodaInterval) * time.Second)
|
||||
for {
|
||||
if entry.CertificatePath != "" && entry.KeyPath != "" {
|
||||
newCert, err := filesystem.ReadFile(entry.CertificatePath)
|
||||
|
@ -92,10 +98,12 @@ func (c *Config) BuildCertificates() []*xtls.Certificate {
|
|||
cert = &newKeyPair
|
||||
}
|
||||
}
|
||||
if newOCSPData, err := ocsp.GetOCSPForCert(cert.Certificate); err != nil {
|
||||
newError("ignoring invalid OCSP").Base(err).AtWarning().WriteToLog()
|
||||
} else if string(newOCSPData) != string(cert.OCSPStaple) {
|
||||
cert.OCSPStaple = newOCSPData
|
||||
if isOcspstapling {
|
||||
if newOCSPData, err := ocsp.GetOCSPForCert(cert.Certificate); err != nil {
|
||||
newError("ignoring invalid OCSP").Base(err).AtWarning().WriteToLog()
|
||||
} else if string(newOCSPData) != string(cert.OCSPStaple) {
|
||||
cert.OCSPStaple = newOCSPData
|
||||
}
|
||||
}
|
||||
certs[index] = cert
|
||||
<-t.C
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue