k6
k6 copied to clipboard
A bash script that creates certificates for tests
What?
We have a couple of certificates that are used in the test hardcoded:
https://github.com/grafana/xk6-grpc/blob/0250ce4280190b0fec8452404cd5456f291b5879/grpc/client_test.go#L860-L865
If we need to regenerate certificates quickly (let's say it expired), we must figure out how.
For instance, the certificate that is hardcoded in clientAuthBad expires in 2024:
openssl x509 -in bad_cert.pem -text -noout
Certificate:
Data:
Version: 3 (0x2)
Serial Number:
24:86:4a:89:1e:fc:00:7d:a2:a1:9f:89:69:ef:ec:12:58:07:f3:99
Signature Algorithm: ecdsa-with-SHA256
Issuer: CN = My CA
Validity
Not Before: Jul 7 10:26:46 2023 GMT
Not After : Jul 6 10:26:46 2024 GMT
The grpc/grpc-go has an excellent example of how to solve this by having a tiny bash script. So we could do something similar.
Why?
This improves test maintainability and developer UX.
An alternative could be for sure generation certificates on the fly.