Skip to content

Commit 1b66879

Browse files
authored
Merge pull request #9167 from weiran-ms/dev/weiran/cloudintpath
🐛Certificate paths in cloud-init scripts should not use a platform-dependent path separator
2 parents 9c3da1f + 470aaf0 commit 1b66879

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

util/secret/certificates.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"crypto/x509/pkix"
2626
"encoding/hex"
2727
"math/big"
28-
"path/filepath"
28+
"path"
2929
"strings"
3030
"time"
3131

@@ -73,25 +73,25 @@ func NewCertificatesForInitialControlPlane(config *bootstrapv1.ClusterConfigurat
7373
certificates := Certificates{
7474
&Certificate{
7575
Purpose: ClusterCA,
76-
CertFile: filepath.Join(certificatesDir, "ca.crt"),
77-
KeyFile: filepath.Join(certificatesDir, "ca.key"),
76+
CertFile: path.Join(certificatesDir, "ca.crt"),
77+
KeyFile: path.Join(certificatesDir, "ca.key"),
7878
},
7979
&Certificate{
8080
Purpose: ServiceAccount,
81-
CertFile: filepath.Join(certificatesDir, "sa.pub"),
82-
KeyFile: filepath.Join(certificatesDir, "sa.key"),
81+
CertFile: path.Join(certificatesDir, "sa.pub"),
82+
KeyFile: path.Join(certificatesDir, "sa.key"),
8383
},
8484
&Certificate{
8585
Purpose: FrontProxyCA,
86-
CertFile: filepath.Join(certificatesDir, "front-proxy-ca.crt"),
87-
KeyFile: filepath.Join(certificatesDir, "front-proxy-ca.key"),
86+
CertFile: path.Join(certificatesDir, "front-proxy-ca.crt"),
87+
KeyFile: path.Join(certificatesDir, "front-proxy-ca.key"),
8888
},
8989
}
9090

9191
etcdCert := &Certificate{
9292
Purpose: EtcdCA,
93-
CertFile: filepath.Join(certificatesDir, "etcd", "ca.crt"),
94-
KeyFile: filepath.Join(certificatesDir, "etcd", "ca.key"),
93+
CertFile: path.Join(certificatesDir, "etcd", "ca.crt"),
94+
KeyFile: path.Join(certificatesDir, "etcd", "ca.key"),
9595
}
9696

9797
// TODO make sure all the fields are actually defined and return an error if not
@@ -124,24 +124,24 @@ func NewControlPlaneJoinCerts(config *bootstrapv1.ClusterConfiguration) Certific
124124
certificates := Certificates{
125125
&Certificate{
126126
Purpose: ClusterCA,
127-
CertFile: filepath.Join(certificatesDir, "ca.crt"),
128-
KeyFile: filepath.Join(certificatesDir, "ca.key"),
127+
CertFile: path.Join(certificatesDir, "ca.crt"),
128+
KeyFile: path.Join(certificatesDir, "ca.key"),
129129
},
130130
&Certificate{
131131
Purpose: ServiceAccount,
132-
CertFile: filepath.Join(certificatesDir, "sa.pub"),
133-
KeyFile: filepath.Join(certificatesDir, "sa.key"),
132+
CertFile: path.Join(certificatesDir, "sa.pub"),
133+
KeyFile: path.Join(certificatesDir, "sa.key"),
134134
},
135135
&Certificate{
136136
Purpose: FrontProxyCA,
137-
CertFile: filepath.Join(certificatesDir, "front-proxy-ca.crt"),
138-
KeyFile: filepath.Join(certificatesDir, "front-proxy-ca.key"),
137+
CertFile: path.Join(certificatesDir, "front-proxy-ca.crt"),
138+
KeyFile: path.Join(certificatesDir, "front-proxy-ca.key"),
139139
},
140140
}
141141
etcdCert := &Certificate{
142142
Purpose: EtcdCA,
143-
CertFile: filepath.Join(certificatesDir, "etcd", "ca.crt"),
144-
KeyFile: filepath.Join(certificatesDir, "etcd", "ca.key"),
143+
CertFile: path.Join(certificatesDir, "etcd", "ca.crt"),
144+
KeyFile: path.Join(certificatesDir, "etcd", "ca.key"),
145145
}
146146

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

173173
return Certificates{

0 commit comments

Comments
 (0)