Skip to content

Commit 2c331a9

Browse files
committed
networking-py: add HTTPS test and CA certificates
Signed-off-by: danbugs <danilochiarlone@gmail.com>
1 parent b3103fa commit 2c331a9

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

examples/networking-py/Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ FROM ${BASE} AS rootfs
88
COPY http_get.py /http_get.py
99
COPY echo_server.py /echo_server.py
1010
COPY urllib_get.py /urllib_get.py
11+
COPY https_test.py /https_test.py
1112

1213
# --- CPIO rootfs builder ---
1314
FROM alpine:3.20 AS cpio
14-
RUN apk add --no-cache cpio findutils
15+
RUN apk add --no-cache cpio findutils ca-certificates
1516
COPY --from=rootfs / /rootfs/
1617

1718
# DNS configuration for glibc's getaddrinfo (added in the cpio stage
@@ -22,4 +23,9 @@ RUN mkdir -p /rootfs/etc && \
2223
echo "hosts: files dns" > /rootfs/etc/nsswitch.conf && \
2324
echo "127.0.0.1 localhost" > /rootfs/etc/hosts
2425

26+
# CA certificates for TLS
27+
RUN mkdir -p /rootfs/etc/ssl/certs /rootfs/usr/lib/ssl && \
28+
cp /etc/ssl/certs/ca-certificates.crt /rootfs/etc/ssl/certs/ && \
29+
ln -sf /etc/ssl/certs/ca-certificates.crt /rootfs/usr/lib/ssl/cert.pem
30+
2531
RUN cd /rootfs && find . | cpio -o -H newc > /output.cpio 2>/dev/null

examples/networking-py/Justfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ run-get:
2222
run-urllib:
2323
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --memory {{memory}} -- /urllib_get.py
2424

25+
# Run HTTPS (TLS) test
26+
run-https:
27+
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --memory {{memory}} -- /https_test.py
28+
2529
# Run echo server
2630
run-echo:
2731
hyperlight-unikraft {{kernel}} --initrd {{initrd}} --memory {{memory}} -- /echo_server.py
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import urllib.request
2+
import sys
3+
4+
print("Testing HTTPS (TLS) through proxied sockets...")
5+
try:
6+
r = urllib.request.urlopen('https://api.github.com', timeout=10)
7+
print(f"Status: {r.status}")
8+
print("SUCCESS: HTTPS works!")
9+
except Exception as e:
10+
print(f"FAILED: {e}")
11+
sys.exit(1)

0 commit comments

Comments
 (0)