-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathnixos.nix
More file actions
91 lines (76 loc) · 2.49 KB
/
nixos.nix
File metadata and controls
91 lines (76 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# SPDX-License-Identifier: MIT
# Derived from:
# https://github.com/NixOS/nixpkgs/blob/4c9ca53890654b5e2fbb22ab8feb1842d81e01c1/nixos/tests/nginx-http3.nix
# Copyright (c) 2003-2024 Eelco Dolstra and the Nixpkgs/NixOS contributors
{ pkgs ? import <nixpkgs> { } }:
let
caCert = builtins.readFile <nixpkgs/nixos/tests/common/acme/server/ca.cert.pem>;
certPath = <nixpkgs/nixos/tests/common/acme/server/acme.test.cert.pem>;
keyPath = <nixpkgs/nixos/tests/common/acme/server/acme.test.key.pem>;
hosts = ''
192.168.2.101 acme.test
'';
in
pkgs.testers.runNixOSTest {
name = "rustls-libssl";
nodes = {
server = { lib, pkgs, ... }: {
networking = {
interfaces.eth1 = {
ipv4.addresses = [
{ address = "192.168.2.101"; prefixLength = 24; }
];
};
extraHosts = hosts;
firewall.allowedTCPPorts = [ 443 ];
firewall.allowedUDPPorts = [ 443 ];
};
security.pki.certificates = [ caCert ];
services.nginx = {
enable = true;
package = pkgs.nginxQuic.override {
modules = [ ];
openssl = pkgs.callPackage ../dist/package.nix { };
};
# Hardcoded sole input accepted by rustls-libssl.
sslCiphers = "HIGH:!aNULL:!MD5";
virtualHosts."acme.test" = {
onlySSL = true;
sslCertificate = certPath;
sslCertificateKey = keyPath;
http2 = true;
# TODO: Needs SSL_CTX_add_custom_ext
#http3 = true;
#http3_hq = false;
#quic = true;
reuseport = true;
root = lib.mkForce (pkgs.runCommandLocal "testdir" {} ''
mkdir "$out"
cat > "$out/index.html" <<EOF
<html><body>Hello World!</body></html>
EOF
'');
};
};
};
client = { pkgs, ... }: {
environment.systemPackages = [ pkgs.curlHTTP3 ];
networking = {
interfaces.eth1 = {
ipv4.addresses = [
{ address = "192.168.2.201"; prefixLength = 24; }
];
};
extraHosts = hosts;
};
security.pki.certificates = [ caCert ];
};
};
testScript = ''
start_all()
server.wait_for_open_port(443)
client.succeed("curl --verbose --http1.1 https://acme.test | grep 'Hello World!'")
client.succeed("curl --verbose --http2-prior-knowledge https://acme.test | grep 'Hello World!'")
#client.succeed("curl --verbose --http3-only https://acme.test | grep 'Hello World!'")
'';
}