mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-06-06 15:47:19 +02:00
prevent out of range when check issuer exist
This commit is contained in:
parent
a692ec818d
commit
c6c523e005
@ -280,12 +280,6 @@ func (a *AutoRenewer) CheckAndRenewCertificates() ([]string, error) {
|
|||||||
}
|
}
|
||||||
if CertExpireSoon(certBytes) || CertIsExpired(certBytes) {
|
if CertExpireSoon(certBytes) || CertIsExpired(certBytes) {
|
||||||
//This cert is expired
|
//This cert is expired
|
||||||
CAName, err := ExtractIssuerName(certBytes)
|
|
||||||
if err != nil {
|
|
||||||
//Maybe self signed. Ignore this
|
|
||||||
log.Println("Unable to extract issuer name for cert " + file.Name())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
DNSName, err := ExtractDomains(certBytes)
|
DNSName, err := ExtractDomains(certBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -296,7 +290,6 @@ func (a *AutoRenewer) CheckAndRenewCertificates() ([]string, error) {
|
|||||||
|
|
||||||
expiredCertList = append(expiredCertList, &ExpiredCerts{
|
expiredCertList = append(expiredCertList, &ExpiredCerts{
|
||||||
Filepath: filepath.Join(certFolder, file.Name()),
|
Filepath: filepath.Join(certFolder, file.Name()),
|
||||||
CA: CAName,
|
|
||||||
Domains: DNSName,
|
Domains: DNSName,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -315,12 +308,6 @@ func (a *AutoRenewer) CheckAndRenewCertificates() ([]string, error) {
|
|||||||
}
|
}
|
||||||
if CertExpireSoon(certBytes) || CertIsExpired(certBytes) {
|
if CertExpireSoon(certBytes) || CertIsExpired(certBytes) {
|
||||||
//This cert is expired
|
//This cert is expired
|
||||||
CAName, err := ExtractIssuerName(certBytes)
|
|
||||||
if err != nil {
|
|
||||||
//Maybe self signed. Ignore this
|
|
||||||
log.Println("Unable to extract issuer name for cert " + file.Name())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
DNSName, err := ExtractDomains(certBytes)
|
DNSName, err := ExtractDomains(certBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -331,7 +318,6 @@ func (a *AutoRenewer) CheckAndRenewCertificates() ([]string, error) {
|
|||||||
|
|
||||||
expiredCertList = append(expiredCertList, &ExpiredCerts{
|
expiredCertList = append(expiredCertList, &ExpiredCerts{
|
||||||
Filepath: filepath.Join(certFolder, file.Name()),
|
Filepath: filepath.Join(certFolder, file.Name()),
|
||||||
CA: CAName,
|
|
||||||
Domains: DNSName,
|
Domains: DNSName,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,11 @@ func ExtractIssuerName(certBytes []byte) (string, error) {
|
|||||||
return "", fmt.Errorf("failed to parse certificate: %v", err)
|
return "", fmt.Errorf("failed to parse certificate: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if exist incase some acme server didn't have org section
|
||||||
|
if len(cert.Issuer.Organization) == 0 {
|
||||||
|
return "", fmt.Errorf("cert didn't have org section exist")
|
||||||
|
}
|
||||||
|
|
||||||
// Extract the issuer name
|
// Extract the issuer name
|
||||||
issuer := cert.Issuer.Organization[0]
|
issuer := cert.Issuer.Organization[0]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user