mirror of
https://github.com/usual2970/certimate.git
synced 2025-06-19 10:50:13 +00:00
Invert the boolean value to match the function name
This commit is contained in:
parent
9a75d2ac8f
commit
56eced3813
@ -137,20 +137,20 @@ func deploy(ctx context.Context, record *models.Record) error {
|
|||||||
func isCertChanged(certificate string, record *models.Record) bool {
|
func isCertChanged(certificate string, record *models.Record) bool {
|
||||||
// 如果证书为空,直接返回false
|
// 如果证书为空,直接返回false
|
||||||
if certificate == "" {
|
if certificate == "" {
|
||||||
return false
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解析证书
|
// 解析证书
|
||||||
cert, err := x509.ParseCertificateFromPEM(certificate)
|
cert, err := x509.ParseCertificateFromPEM(certificate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.GetApp().Logger().Error("解析证书失败", "err", err)
|
app.GetApp().Logger().Error("解析证书失败", "err", err)
|
||||||
return false
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 遍历域名列表,检查是否都在证书中,找到第一个不存在证书中域名时提前返回false
|
// 遍历域名列表,检查是否都在证书中,找到第一个不存在证书中域名时提前返回false
|
||||||
for _, domain := range strings.Split(record.GetString("domain"), ";") {
|
for _, domain := range strings.Split(record.GetString("domain"), ";") {
|
||||||
if !slices.Contains(cert.DNSNames, domain) && !slices.Contains(cert.DNSNames, "*."+removeLastSubdomain(domain)) {
|
if !slices.Contains(cert.DNSNames, domain) && !slices.Contains(cert.DNSNames, "*."+removeLastSubdomain(domain)) {
|
||||||
return false
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,30 +166,30 @@ func isCertChanged(certificate string, record *models.Record) bool {
|
|||||||
switch bitSize {
|
switch bitSize {
|
||||||
case 2048:
|
case 2048:
|
||||||
// RSA2048
|
// RSA2048
|
||||||
if applyConfig.KeyAlgorithm != "" && applyConfig.KeyAlgorithm != "RSA2048" { return false }
|
if applyConfig.KeyAlgorithm != "" && applyConfig.KeyAlgorithm != "RSA2048" { return true }
|
||||||
case 3072:
|
case 3072:
|
||||||
// RSA3072
|
// RSA3072
|
||||||
if applyConfig.KeyAlgorithm != "RSA3072" { return false }
|
if applyConfig.KeyAlgorithm != "RSA3072" { return true }
|
||||||
case 4096:
|
case 4096:
|
||||||
// RSA4096
|
// RSA4096
|
||||||
if applyConfig.KeyAlgorithm != "RSA4096" { return false }
|
if applyConfig.KeyAlgorithm != "RSA4096" { return true }
|
||||||
case 8192:
|
case 8192:
|
||||||
// RSA8192
|
// RSA8192
|
||||||
if applyConfig.KeyAlgorithm != "RSA8192" { return false }
|
if applyConfig.KeyAlgorithm != "RSA8192" { return true }
|
||||||
}
|
}
|
||||||
case *ecdsa.PublicKey:
|
case *ecdsa.PublicKey:
|
||||||
bitSize := pubkey.Curve.Params().BitSize
|
bitSize := pubkey.Curve.Params().BitSize
|
||||||
switch bitSize {
|
switch bitSize {
|
||||||
case 256:
|
case 256:
|
||||||
// EC256
|
// EC256
|
||||||
if applyConfig.KeyAlgorithm != "EC256" { return false }
|
if applyConfig.KeyAlgorithm != "EC256" { return true }
|
||||||
case 384:
|
case 384:
|
||||||
// EC384
|
// EC384
|
||||||
if applyConfig.KeyAlgorithm != "EC384" { return false }
|
if applyConfig.KeyAlgorithm != "EC384" { return true }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeLastSubdomain(domain string) string {
|
func removeLastSubdomain(domain string) string {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user