mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 06:09:39 +08:00
loadbalancercertificates: make code compatible with go-1.9
Upstream go commit id https://github.com/golang/go/commit/34920b8713fa93ee50ee8963949728c1569e6017
This commit is contained in:
@@ -2,6 +2,7 @@ package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/x509"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -74,10 +75,21 @@ func (man *SLoadbalancerCertificateManager) validateCertKey(ctx context.Context,
|
||||
}
|
||||
}
|
||||
cert := certV.Certificates[0]
|
||||
certPubKeyAlgo := cert.PublicKeyAlgorithm.String()
|
||||
if !LB_TLS_CERT_PUBKEY_ALGOS.Has(certPubKeyAlgo) {
|
||||
return nil, httperrors.NewInputParameterError("invalid cert pubkey algorithm: %s, want %s",
|
||||
certPubKeyAlgo, LB_TLS_CERT_PUBKEY_ALGOS.String())
|
||||
var certPubKeyAlgo string
|
||||
{
|
||||
// x509.PublicKeyAlgorithm.String() is only available since go1.10
|
||||
switch cert.PublicKeyAlgorithm {
|
||||
case x509.RSA:
|
||||
certPubKeyAlgo = LB_TLS_CERT_PUBKEY_ALGO_RSA
|
||||
case x509.ECDSA:
|
||||
certPubKeyAlgo = LB_TLS_CERT_PUBKEY_ALGO_ECDSA
|
||||
default:
|
||||
certPubKeyAlgo = fmt.Sprintf("algo %#v", cert.PublicKeyAlgorithm)
|
||||
}
|
||||
if !LB_TLS_CERT_PUBKEY_ALGOS.Has(certPubKeyAlgo) {
|
||||
return nil, httperrors.NewInputParameterError("invalid cert pubkey algorithm: %s, want %s",
|
||||
certPubKeyAlgo, LB_TLS_CERT_PUBKEY_ALGOS.String())
|
||||
}
|
||||
}
|
||||
err := pkeyV.MatchCertificate(cert)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user