Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow-up from #943 #945

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions controller/internal/enforcer/applicationproxy/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,16 @@ func (p *Config) newBaseTLSClientConfig() *tls.Config {
func (p *Config) GetClientCertificateFunc(_ *tls.CertificateRequestInfo) (*tls.Certificate, error) {
p.RLock()
defer p.RUnlock()
if p.cert != nil {
if p.cert != nil && len(p.cert.Certificate) > 0 {
cert, err := x509.ParseCertificate(p.cert.Certificate[0])
if err != nil {
zap.L().Error("http: Cannot build the cert chain")
zap.L().Error("http: client-certs: cannot build the cert chain: failed to parse cert[0]", zap.Error(err))
}
if cert != nil {
by, _ := x509CertToPem(cert)
pemCert, err := buildCertChain(by, p.secrets.PublicSecrets().CertAuthority())
if err != nil {
zap.L().Error("http: Cannot build the cert chain")
zap.L().Error("http: client-certs: cannot build the cert chain", zap.Error(err))
}
var certChain tls.Certificate
var certDERBlock *pem.Block
Expand Down Expand Up @@ -466,7 +466,7 @@ func (p *Config) GetCertificateFunc(clientHello *tls.ClientHelloInfo) (*tls.Cert
}

func buildCertChain(certPEM, caPEM []byte) ([]byte, error) {
zap.L().Debug("http: BEFORE in buildCertChain certPEM: ", zap.String("certPEM:", string(certPEM)), zap.String("caPEM: ", string(caPEM)))
zap.L().Debug("http: buildCertChain() call", zap.String("certPEM", string(certPEM)), zap.String("caPEM", string(caPEM)))
certChain := []*x509.Certificate{}
clientPEMBlock := certPEM

Expand Down Expand Up @@ -498,9 +498,9 @@ func buildCertChain(certPEM, caPEM []byte) ([]byte, error) {
return nil, fmt.Errorf("invalid pem block type: %s", certDERBlock.Type)
}
}
by, _ := x509CertChainToPem(certChain)
zap.L().Debug("http: After building the cert chain: ", zap.String("certChain: ", string(by)))
return x509CertChainToPem(certChain)
certChainBytes, err := x509CertChainToPem(certChain)
zap.L().Debug("http: buildCertChain() return", zap.String("certChainBytes", string(certChainBytes)), zap.Error(err))
return certChainBytes, err
}

// x509CertChainToPem converts chain of x509 certs to byte.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ func (e *Enforcer) Enforce(contextID string, puInfo *policy.PUInfo) error {
sdsServer, err := envoyproxy.NewSdsServer(contextID, puInfo, caPool, e.secrets)
if err != nil {
zap.L().Error("Cannot create and run SdsServer", zap.Error(err))
ingressServer.Stop()
egressServer.Stop()
return err
}
// Add the EnvoyServers to our cache
Expand Down