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

🐛Certificate paths in cloud-init scripts should not use a platform-dependent path separator #9167

Merged
Merged
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
36 changes: 18 additions & 18 deletions util/secret/certificates.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"crypto/x509/pkix"
"encoding/hex"
"math/big"
"path/filepath"
"path"
"strings"
"time"

Expand Down Expand Up @@ -73,25 +73,25 @@ func NewCertificatesForInitialControlPlane(config *bootstrapv1.ClusterConfigurat
certificates := Certificates{
&Certificate{
Purpose: ClusterCA,
CertFile: filepath.Join(certificatesDir, "ca.crt"),
KeyFile: filepath.Join(certificatesDir, "ca.key"),
CertFile: path.Join(certificatesDir, "ca.crt"),
KeyFile: path.Join(certificatesDir, "ca.key"),
},
&Certificate{
Purpose: ServiceAccount,
CertFile: filepath.Join(certificatesDir, "sa.pub"),
KeyFile: filepath.Join(certificatesDir, "sa.key"),
CertFile: path.Join(certificatesDir, "sa.pub"),
KeyFile: path.Join(certificatesDir, "sa.key"),
},
&Certificate{
Purpose: FrontProxyCA,
CertFile: filepath.Join(certificatesDir, "front-proxy-ca.crt"),
KeyFile: filepath.Join(certificatesDir, "front-proxy-ca.key"),
CertFile: path.Join(certificatesDir, "front-proxy-ca.crt"),
KeyFile: path.Join(certificatesDir, "front-proxy-ca.key"),
},
}

etcdCert := &Certificate{
Purpose: EtcdCA,
CertFile: filepath.Join(certificatesDir, "etcd", "ca.crt"),
KeyFile: filepath.Join(certificatesDir, "etcd", "ca.key"),
CertFile: path.Join(certificatesDir, "etcd", "ca.crt"),
KeyFile: path.Join(certificatesDir, "etcd", "ca.key"),
}

// TODO make sure all the fields are actually defined and return an error if not
Expand Down Expand Up @@ -124,24 +124,24 @@ func NewControlPlaneJoinCerts(config *bootstrapv1.ClusterConfiguration) Certific
certificates := Certificates{
&Certificate{
Purpose: ClusterCA,
CertFile: filepath.Join(certificatesDir, "ca.crt"),
KeyFile: filepath.Join(certificatesDir, "ca.key"),
CertFile: path.Join(certificatesDir, "ca.crt"),
KeyFile: path.Join(certificatesDir, "ca.key"),
},
&Certificate{
Purpose: ServiceAccount,
CertFile: filepath.Join(certificatesDir, "sa.pub"),
KeyFile: filepath.Join(certificatesDir, "sa.key"),
CertFile: path.Join(certificatesDir, "sa.pub"),
KeyFile: path.Join(certificatesDir, "sa.key"),
},
&Certificate{
Purpose: FrontProxyCA,
CertFile: filepath.Join(certificatesDir, "front-proxy-ca.crt"),
KeyFile: filepath.Join(certificatesDir, "front-proxy-ca.key"),
CertFile: path.Join(certificatesDir, "front-proxy-ca.crt"),
KeyFile: path.Join(certificatesDir, "front-proxy-ca.key"),
},
}
etcdCert := &Certificate{
Purpose: EtcdCA,
CertFile: filepath.Join(certificatesDir, "etcd", "ca.crt"),
KeyFile: filepath.Join(certificatesDir, "etcd", "ca.key"),
CertFile: path.Join(certificatesDir, "etcd", "ca.crt"),
KeyFile: path.Join(certificatesDir, "etcd", "ca.key"),
}

// TODO make sure all the fields are actually defined and return an error if not
Expand All @@ -167,7 +167,7 @@ func NewControlPlaneJoinCerts(config *bootstrapv1.ClusterConfiguration) Certific
// NewCertificatesForWorker return an initialized but empty set of CA certificates needed to bootstrap a cluster.
func NewCertificatesForWorker(caCertPath string) Certificates {
if caCertPath == "" {
caCertPath = filepath.Join(DefaultCertificatesDir, "ca.crt")
caCertPath = path.Join(DefaultCertificatesDir, "ca.crt")
}

return Certificates{
Expand Down