Skip to content

Commit a0e5d59

Browse files
authored
Launch Nexus using a self-signed x.509 certificate (#1287)
Part of #249 This PR forces Nexus's external interface to be served via HTTPS when deployed by the sled-agent. - The packaging system expects to find these certificates within `./out/certs`, named `cert.pem` and `key.pem`. - `./tools/create_self_signed_cert.sh` is capable of creating a self-signed certificate.
1 parent c18a8fe commit a0e5d59

File tree

4 files changed

+49
-1
lines changed

4 files changed

+49
-1
lines changed

docs/how-to-run.adoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ the networking bits are temporary, so a reboot should always clear them.
4343

4444
Both scripts must be run as root, e.g, `pfexec ./tools/create_virtual_hardware.sh`.
4545

46+
=== Make me a certificate!
47+
48+
Nexus's external interface will typically be served using public-facing x.509
49+
certificate. While we are still configuring the mechanism to integrate this real
50+
certificate into the package system, `./tools/create_self_signed_cert.sh` can be
51+
used to generate an equivalent self-signed certificate.
52+
4653
== Deploying Omicron
4754

4855
The control plane repository contains a packaging tool which bundles binaries

package-manifest.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ to = "/var/svc/manifest/site/nexus"
2525
[[package.omicron-nexus.paths]]
2626
from = "out/console-assets"
2727
to = "/var/nexus/static"
28+
# Note, we could just map the whole "out/certs" directory, but this ensures
29+
# both files exist.
30+
[[package.omicron-nexus.paths]]
31+
from = "out/certs/cert.pem"
32+
to = "/var/nexus/certs/cert.pem"
33+
[[package.omicron-nexus.paths]]
34+
from = "out/certs/key.pem"
35+
to = "/var/nexus/certs/key.pem"
2836

2937
[package.oximeter-collector]
3038
rust.binary_names = ["oximeter"]

sled-agent/src/services.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,12 @@ impl ServiceManager {
324324
dropshot_external: ConfigDropshot {
325325
bind_address: SocketAddr::V6(external_address),
326326
request_body_max_bytes: 1048576,
327-
..Default::default()
327+
tls: Some(
328+
dropshot::ConfigTls {
329+
cert_file: PathBuf::from("/var/nexus/certs/cert.pem"),
330+
key_file: PathBuf::from("/var/nexus/certs/key.pem"),
331+
}
332+
),
328333
},
329334
dropshot_internal: ConfigDropshot {
330335
bind_address: SocketAddr::V6(internal_address),

tools/create_self_signed_cert.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
# Creates a self-signed certificate.
4+
#
5+
# For those with access, certificates are available in:
6+
#
7+
# https://github.com/oxidecomputer/configs/tree/master/nginx/ssl/wildcard.oxide-preview.com
8+
9+
set -eu
10+
11+
# Set the CWD to Omicron's source.
12+
SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
13+
cd "${SOURCE_DIR}/.."
14+
15+
OUTPUT_DIR="out/certs"
16+
CERT_PATH="$OUTPUT_DIR/cert.pem"
17+
KEY_PATH="$OUTPUT_DIR/key.pem"
18+
19+
mkdir -p "$OUTPUT_DIR"
20+
21+
openssl req -newkey rsa:4096 \
22+
-x509 \
23+
-sha256 \
24+
-days 3650 \
25+
-nodes \
26+
-out "$CERT_PATH" \
27+
-keyout "$KEY_PATH" \
28+
-subj '/CN=localhost'

0 commit comments

Comments
 (0)