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

Adding SAN to fleet autoscaler certs and updating documentation #1910

Merged
merged 3 commits into from
Nov 30, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,32 @@ Every webhook that you wish to install a trusted certificate will need to go thr
openssl genrsa -out webhook.key 2048
```

Once the key is created, you’ll generate the certificate signing request, use valid hostname which is `autoscaler-tls-service.default.svc` as `Common Name (eg, fully qualified host name)` when prompted:
Next create configuration file `cert.conf` for the certificate signing request:
```
openssl req -new -key webhook.key -out webhook.csr
[req]
distinguished_name = req_distinguished_name
req_extensions = v3_req
prompt = no
[req_distinguished_name]
CN = autoscaler-tls-service.default.svc
[v3_req]
keyUsage = digitalSignature
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also use the existing configurations in openssl.cnf and only set SAN. Here is an example of doing it in the old version of Agones documentations: https://1-4-0.agones.dev/site/docs/advanced/allocator-service/#server-tls-certificate

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oooh!

I have no strong opinions either way. Whichever is easier to explain?

Do we feel like having a file better, because it's easier for automation tools to utilise?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am happy to change it to use the /etc/ssl/openssl.cnf, but my thinking is that if you use that we are appending extra config to a fairly chunk example file. Whereas if we use a custom cert.conf it is easier for people to follow what is actually happening.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am happy to change it to use the /etc/ssl/openssl.cnf, but my thinking is that if you use that we are appending extra config to a fairly chunk example file. Whereas if we use a custom cert.conf it is easier for people to follow what is actually happening.

Yeah, I would agree. Also wouldn't want people editing/thinking they have to edit the /etc/ssl/openssl.cnf file either.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall I keep it as is then?

[alt_names]
DNS.1 = autoscaler-tls-service.default.svc
```

Generate the certificate signing request, use valid hostname which in this case will be `autoscaler-tls-service.default.svc` as `Common Name (eg, fully qualified host name)` as well as `DNS.1` in the `alt_names` section of the config file.

Check the [Kubernetes documentation](https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#a-aaaa-records) to see how Services get assigned DNS entries.
```
openssl req -new -out webhook.csr -key webhook.key -config cert.conf
```

Once that’s done, you’ll sign the CSR, which requires the CA root key:
```
openssl x509 -req -in webhook.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out webhook.crt -days 500 -sha256
openssl x509 -req -in webhook.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out webhook.crt -days 500 -sha256 -extfile cert.conf -extensions v3_req
```
This would generate webhook.crt certificate

Expand Down
120 changes: 60 additions & 60 deletions test/e2e/fleetautoscaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,76 +461,76 @@ func TestAutoscalerWebhook(t *testing.T) {

var webhookKey = `
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAxNq5ql070cs/foKC+Abj6ETgcIq8HJlYT85wbl8wE5sUqsGx
5iItWZMwFJpEFyW97YNOizc8dYOAGCSLUeEY1aHg0vVSj3tV3jjVD82PtSGhTuE8
HGN5WdzEHavJHraRZB4wYMdjm4cFB6TJ3k8qBz5I8Rjp9CcLtpXTcvm0uWieScVy
yOvhO3XCYXbGo1HLj4wkxL+bYrci8XltTICXmQxT365+YmGNWvaWAUYKm2krmzdv
ObZBowzXFohWIsCYpGMaVRbVoYHry/a1S/DXxQ32WuoyRqnFERrV8mrq6kxYQ0Lc
GvWay5n/p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+6WnYHu0Vq8Hr3/
h2ccwwKBgQCha4ox+SaXzlYROr1qge8xgqK+lpg1i2f32PgK3Ipodjk3esAuzeNM
L5o5pDLorHu4EFtveIneRsV+kf8YPVuid18lYzMAJBqlXvcUik2Izk57cWB/P9so
3/03jXI8iT8BbIU+PoII2EvQEPeAI07BYMU9cvsiFvFoB6z162DJhw==
MIIEpQIBAAKCAQEAzTtFY02SAY4jHiryJbBRT4+2wn1OlqL4WTWUFtKaWEjm+gAn
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that's awesome - so we now also know that using a SAN works with the current Agones install and Go toolchain.

Fantastic!

vLlmNB/dBPL36r1vDbYGPO2MiWF5ULfoe1y/YsQzmwQLnGFhEX5Ou72J2pHQfa1h
VqYiLDz7Pi70qxjABIh/4U/x6x6nfDpvk3a0PBcCnPDDrJvkqpYqJnqfYkKT7LNr
NYCTn12RTIRJTxffDkuQBs9y4RGhmX0Nh9bb5iwpYXQRrKHnwMniR1D9MvJ27aKC
KwpDR+TkdYl/FXYIguFgipPUdw78KYcFA8DJipwkyIqcRvWml1o5yhhwJpNDck3s
S73g+IvoF/YPRy42dCQHhRu4b+JoqOT2jpUD8QIDAQABAoIBAD0orpLbKOmBvAFf
du24T2LQRvxKb0MAqdWb29e5RvmMMBjMNwtMjKJ35Ft3NF4luZRybAV4HOtLuuVN
CODKUNZT9bT6TaN6eXzHERttbklOLr1lD57Mv15DhfOP9qWOKJqxOrqgIk2YwvyI
RXvCYg+OI980+HrVsh0Lxt/Upu6Ws84L+PHSr0McAr7bWaR2ATRKsfQYxNFTtk3v
7ckSGzyIFCy7ijE4g5m2MrZZb/AUzaXfp8PSZgoFC+2dQcKhPshJb9tEBHAv9wPc
JkKZZfmR5n4VbtRekvf9rU5oODfbDOHXzt8b3dsskiZvAbeBdrHVS0kXrPsKj4Li
a1OVRokCgYEA8FKB88YK3PYNH+X7nlUWLHsXjbP9r8bMtYBuvPKkBI06gvJfrDKr
cOh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