Skip to content

Commit 4a1b32d

Browse files
committed
[DEVOPS-1149] Make generated TLS setup configurable
This is a squashed version of PR input-output-hk#3895
1 parent 40ece3b commit 4a1b32d

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed

sample-wallet-config.nix

+28
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,32 @@
3737

3838
## Primarily used for troubleshooting.
3939
#additionalNodeArgs = "";
40+
41+
## TLS configuration
42+
# tlsConfig = {
43+
# organization = "Company Name";
44+
#
45+
# caCommonName = "Company Name Self-Signed Root CA";
46+
# caEexpiryDays = 3650;
47+
#
48+
# serverCommonName = "Company Name Wallet Node";
49+
# serverExpiryDays = 365;
50+
# serverAltDNS = [
51+
# "localhost"
52+
# "localhost.localdomain"
53+
# "127.0.0.1"
54+
# "::1"
55+
# ## WARNING: in case the wallet node is accessed through port forwarding,
56+
# ## the externally-visible address MUST be provided in this list
57+
# ## (not as the first entry, if it's an IP address).
58+
# ];
59+
# ## Set this entry if you only want to add entries to the AltDNS list,
60+
# ## instead of overriding it completely:
61+
# serverAltDNSExtra = [
62+
# "8.8.8.8"
63+
# ];
64+
#
65+
# clientCommonName = "Company Name Wallet Node Client";
66+
# clientExpiryDays = 365;
67+
# };
4068
}

scripts/launch/connect-to-cluster/default.nix

+44-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ with import ../../../lib.nix;
2323
, useLegacyDataLayer ? false
2424
, extraParams ? ""
2525
, useStackBinaries ? false
26+
, tlsConfig ? {}
2627
}:
2728

2829
# TODO: DEVOPS-159: relays DNS should be more predictable
@@ -82,6 +83,47 @@ let
8283
-H "Content-Type: application/json; charset=utf-8" \
8384
"https://${walletListen}/$request_path" "$@"
8485
'';
86+
tlsConfigResultant = {
87+
organization = "Company Name";
88+
89+
caCommonName = "Company Name Self-Signed Root CA";
90+
caEexpiryDays = 3650;
91+
92+
serverCommonName = "Company Name Wallet Node";
93+
serverExpiryDays = 365;
94+
serverAltDNS = [
95+
"localhost"
96+
"localhost.localdomain"
97+
"127.0.0.1"
98+
"::1"
99+
];
100+
serverAltDNSExtra = [];
101+
102+
clientCommonName = "Company Name Wallet Node Client";
103+
clientExpiryDays = 365;
104+
} // tlsConfig;
105+
tlsConfigFile = let cfg = tlsConfigResultant; in writeText "tls-config-${environment}.yaml" (''
106+
${environments.${environment}.confKey}:
107+
tls:
108+
ca:
109+
organization: ${cfg.organization}
110+
commonName: ${cfg.caCommonName}
111+
expiryDays: ${toString cfg.caEexpiryDays}
112+
113+
server:
114+
organization: ${cfg.organization}
115+
commonName: ${cfg.serverCommonName}
116+
expiryDays: ${toString cfg.serverExpiryDays}
117+
altDNS:
118+
'' +
119+
(let sep = " - "; in sep + (concatStringsSep ("\n" + sep) (cfg.serverAltDNS ++ cfg.serverAltDNSExtra)) + "\n")
120+
+ ''
121+
####
122+
clients:
123+
- organization: ${cfg.organization}
124+
commonName: ${cfg.clientCommonName}
125+
expiryDays: ${toString cfg.clientExpiryDays}
126+
'');
85127

86128
in writeScript "${executable}-connect-to-${environment}" ''
87129
#!${stdenv.shell}
@@ -111,7 +153,8 @@ in writeScript "${executable}-connect-to-${environment}" ''
111153
${executables.x509gen} \
112154
--server-out-dir ${stateDir}/tls/server \
113155
--clients-out-dir ${stateDir}/tls/client \
114-
${configurationArgs}
156+
--configuration-file ${tlsConfigFile} \
157+
--configuration-key ${environments.${environment}.confKey}
115158
fi
116159
ln -sf ${curlScript} ${stateDir}/curl
117160
''}

0 commit comments

Comments
 (0)