Skip to content

Commit 34121f2

Browse files
committed
uses runners temp for certs
1 parent f7dd047 commit 34121f2

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

.github/workflows/ci.yml

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jobs:
1616
- 2375:2375
1717
options: >-
1818
--privileged
19-
--tmpfs /var/lib/docker
2019
2120
# Docker with TLS (secure TCP)
2221
docker-tls:
@@ -27,9 +26,8 @@ jobs:
2726
- 2376:2376
2827
options: >-
2928
--privileged
30-
--tmpfs /var/lib/docker
3129
volumes:
32-
- /tmp/certs:/certs
30+
- ${{ github.workspace }}/certs:/certs
3331

3432
strategy:
3533
matrix:
@@ -50,28 +48,28 @@ jobs:
5048

5149
- name: Generate TLS certs for Docker
5250
run: |
53-
mkdir -p /tmp/certs
51+
mkdir -p ${{ github.workspace }}/certs
5452
5553
# Generate CA key and cert
56-
openssl genrsa -out /tmp/certs/ca-key.pem 2048
57-
openssl req -x509 -new -nodes -key /tmp/certs/ca-key.pem -sha256 -days 365 -out /tmp/certs/ca.pem -subj "/CN=docker-ca"
54+
openssl genrsa -out ${{ github.workspace }}/certs/ca-key.pem 2048
55+
openssl req -x509 -new -nodes -key ${{ github.workspace }}/certs/ca-key.pem -sha256 -days 365 -out ${{ github.workspace }}/certs/ca.pem -subj "/CN=docker-ca"
5856
5957
# Generate server key and CSR
60-
openssl genrsa -out /tmp/certs/server-key.pem 2048
61-
openssl req -new -key /tmp/certs/server-key.pem -out /tmp/certs/server.csr -subj "/CN=localhost"
58+
openssl genrsa -out ${{ github.workspace }}/certs/server-key.pem 2048
59+
openssl req -new -key ${{ github.workspace }}/certs/server-key.pem -out ${{ github.workspace }}/certs/server.csr -subj "/CN=localhost"
6260
6361
# Sign server cert with CA
64-
openssl x509 -req -in /tmp/certs/server.csr -CA /tmp/certs/ca.pem -CAkey /tmp/certs/ca-key.pem -CAcreateserial -out /tmp/certs/server-cert.pem -days 365 -sha256
62+
openssl x509 -req -in ${{ github.workspace }}/certs/server.csr -CA ${{ github.workspace }}/certs/ca.pem -CAkey ${{ github.workspace }}/certs/ca-key.pem -CAcreateserial -out ${{ github.workspace }}/certs/server-cert.pem -days 365 -sha256
6563
6664
# Generate client key and CSR
67-
openssl genrsa -out /tmp/certs/key.pem 2048
68-
openssl req -new -key /tmp/certs/key.pem -out /tmp/certs/client.csr -subj "/CN=client"
65+
openssl genrsa -out ${{ github.workspace }}/certs/key.pem 2048
66+
openssl req -new -key ${{ github.workspace }}/certs/key.pem -out ${{ github.workspace }}/certs/client.csr -subj "/CN=client"
6967
7068
# Sign client cert with CA
71-
openssl x509 -req -in /tmp/certs/client.csr -CA /tmp/certs/ca.pem -CAkey /tmp/certs/ca-key.pem -CAcreateserial -out /tmp/certs/cert.pem -days 365 -sha256
69+
openssl x509 -req -in ${{ github.workspace }}/certs/client.csr -CA ${{ github.workspace }}/certs/ca.pem -CAkey ${{ github.workspace }}/certs/ca-key.pem -CAcreateserial -out ${{ github.workspace }}/certs/cert.pem -days 365 -sha256
7270
7371
# create pfx
74-
openssl pkcs12 -export -out /tmp/certs/client.pfx -inkey /tmp/certs/key.pem -in /tmp/certs/cert.pem -certfile /tmp/certs/ca.pem -passout pass:
72+
openssl pkcs12 -export -out ${{ github.workspace }}/certs/client.pfx -inkey ${{ github.workspace }}/certs/key.pem -in ${{ github.workspace }}/certs/cert.pem -certfile ${{ github.workspace }}/certs/ca.pem -passout pass:
7573
7674
- name: Wait for Docker (no TLS) to be healthy
7775
run: |
@@ -90,9 +88,9 @@ jobs:
9088
run: |
9189
for i in {1..10}; do
9290
if docker --host=tcp://localhost:2376 --tlsverify \
93-
--tlscacert=/tmp/certs/ca.pem \
94-
--tlscert=/tmp/certs/cert.pem \
95-
--tlskey=/tmp/certs/key.pem version; then
91+
--tlscacert=${{ github.workspace }}/certs/ca.pem \
92+
--tlscert=${{ github.workspace }}/certs/cert.pem \
93+
--tlskey=${{ github.workspace }}/certs/key.pem version; then
9694
echo "Docker (TLS) is ready!"
9795
exit 0
9896
fi

test/Docker.DotNet.Tests/TestFixture.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.IO;
12
using System.Net.Security;
23
using System.Security.Cryptography.X509Certificates;
34
using Docker.DotNet.X509;
@@ -37,13 +38,14 @@ public TestFixture(IMessageSink messageSink)
3738

3839
try
3940
{
41+
var tempDir = Environment.GetEnvironmentVariable("GITHUB_WORKSPACE");
4042
#if NET9_0_OR_GREATER
41-
var credentials = new CertificateCredentials(X509CertificateLoader.LoadPkcs12FromFile("/tmp/certs/client.pfx", ""))
43+
var credentials = new CertificateCredentials(X509CertificateLoader.LoadPkcs12FromFile(Path.Combine(tempDir, "certs", "client.pfx"), ""))
4244
{
4345
ServerCertificateValidationCallback = ValidateServerCertificate
4446
};
4547
#else
46-
var credentials = new CertificateCredentials(new X509Certificate2("/tmp/certs/client.pfx", ""))
48+
var credentials = new CertificateCredentials(new X509Certificate2(Path.Combine(tempDir, "certs", "client.pfx"), ""))
4749
{
4850
ServerCertificateValidationCallback = ValidateServerCertificate
4951
};

0 commit comments

Comments
 (0)