Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
97baadab
Commit
97baadab
authored
Jul 06, 2015
by
Yu-Ju Hong
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10711 from eparis/self-sign-cert-san
Do not create subject alt dns names for kubelet self signed certs
parents
4d861270
cde68d29
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
11 deletions
+10
-11
server.go
cmd/kube-apiserver/app/server.go
+5
-1
server.go
cmd/kubelet/app/server.go
+1
-1
crypto.go
pkg/util/crypto.go
+4
-9
No files found.
cmd/kube-apiserver/app/server.go
View file @
97baadab
...
...
@@ -449,7 +449,11 @@ func (s *APIServer) Run(_ []string) error {
s
.
TLSCertFile
=
path
.
Join
(
s
.
CertDirectory
,
"apiserver.crt"
)
s
.
TLSPrivateKeyFile
=
path
.
Join
(
s
.
CertDirectory
,
"apiserver.key"
)
// TODO (cjcullen): Is PublicAddress the right address to sign a cert with?
if
err
:=
util
.
GenerateSelfSignedCert
(
config
.
PublicAddress
.
String
(),
s
.
TLSCertFile
,
s
.
TLSPrivateKeyFile
,
config
.
ServiceReadWriteIP
);
err
!=
nil
{
alternateIPs
:=
[]
net
.
IP
{
config
.
ServiceReadWriteIP
}
alternateDNS
:=
[]
string
{
"kubernetes.default.svc"
,
"kubernetes.default"
,
"kubernetes"
}
// It would be nice to set a fqdn subject alt name, but only the kubelets know, the apiserver is clueless
// alternateDNS = append(alternateDNS, "kubernetes.default.svc.CLUSTER.DNS.NAME")
if
err
:=
util
.
GenerateSelfSignedCert
(
config
.
PublicAddress
.
String
(),
s
.
TLSCertFile
,
s
.
TLSPrivateKeyFile
,
alternateIPs
,
alternateDNS
);
err
!=
nil
{
glog
.
Errorf
(
"Unable to generate self signed cert: %v"
,
err
)
}
else
{
glog
.
Infof
(
"Using self-signed cert (%s, %s)"
,
s
.
TLSCertFile
,
s
.
TLSPrivateKeyFile
)
...
...
cmd/kubelet/app/server.go
View file @
97baadab
...
...
@@ -395,7 +395,7 @@ func (s *KubeletServer) InitializeTLS() (*kubelet.TLSOptions, error) {
if
s
.
TLSCertFile
==
""
&&
s
.
TLSPrivateKeyFile
==
""
{
s
.
TLSCertFile
=
path
.
Join
(
s
.
CertDirectory
,
"kubelet.crt"
)
s
.
TLSPrivateKeyFile
=
path
.
Join
(
s
.
CertDirectory
,
"kubelet.key"
)
if
err
:=
util
.
GenerateSelfSignedCert
(
nodeutil
.
GetHostname
(
s
.
HostnameOverride
),
s
.
TLSCertFile
,
s
.
TLSPrivateKeyFile
,
nil
);
err
!=
nil
{
if
err
:=
util
.
GenerateSelfSignedCert
(
nodeutil
.
GetHostname
(
s
.
HostnameOverride
),
s
.
TLSCertFile
,
s
.
TLSPrivateKeyFile
,
nil
,
nil
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"unable to generate self signed cert: %v"
,
err
)
}
glog
.
V
(
4
)
.
Infof
(
"Using self-signed cert (%s, %s)"
,
s
.
TLSCertFile
,
s
.
TLSPrivateKeyFile
)
...
...
pkg/util/crypto.go
View file @
97baadab
...
...
@@ -35,10 +35,11 @@ import (
// GenerateSelfSignedCert creates a self-signed certificate and key for the given host.
// Host may be an IP or a DNS name
// You may also specify additional subject alt names (either ip or dns names) for the certificate
// The certificate will be created with file mode 0644. The key will be created with file mode 0600.
// If the certificate or key files already exist, they will be overwritten.
// Any parent directories of the certPath or keyPath will be created as needed with file mode 0755.
func
GenerateSelfSignedCert
(
host
,
certPath
,
keyPath
string
,
ServiceReadWriteIP
net
.
IP
)
error
{
func
GenerateSelfSignedCert
(
host
,
certPath
,
keyPath
string
,
alternateIPs
[]
net
.
IP
,
alternateDNS
[]
string
)
error
{
priv
,
err
:=
rsa
.
GenerateKey
(
rand
.
Reader
,
2048
)
if
err
!=
nil
{
return
err
...
...
@@ -63,14 +64,8 @@ func GenerateSelfSignedCert(host, certPath, keyPath string, ServiceReadWriteIP n
template
.
DNSNames
=
append
(
template
.
DNSNames
,
host
)
}
if
ServiceReadWriteIP
!=
nil
{
template
.
IPAddresses
=
append
(
template
.
IPAddresses
,
ServiceReadWriteIP
)
}
// It would be nice to have the next line, but only the kubelets know the fqdn, the apiserver is clueless
// template.DNSNames = append(template.DNSNames, "kubernetes.default.svc.CLUSTER.DNS.NAME")
template
.
DNSNames
=
append
(
template
.
DNSNames
,
"kubernetes.default.svc"
)
template
.
DNSNames
=
append
(
template
.
DNSNames
,
"kubernetes.default"
)
template
.
DNSNames
=
append
(
template
.
DNSNames
,
"kubernetes"
)
template
.
IPAddresses
=
append
(
template
.
IPAddresses
,
alternateIPs
...
)
template
.
DNSNames
=
append
(
template
.
DNSNames
,
alternateDNS
...
)
derBytes
,
err
:=
x509
.
CreateCertificate
(
rand
.
Reader
,
&
template
,
&
template
,
&
priv
.
PublicKey
,
priv
)
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment