Skip to content

Commit

Permalink
Refactor test_server.cpp to add SSL certificate loading support
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardodebenedictis committed Sep 24, 2024
1 parent 303956f commit 0bfbd12
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 0 deletions.
Binary file added tests/cert.crt
Binary file not shown.
29 changes: 29 additions & 0 deletions tests/cert.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
-----BEGIN CERTIFICATE-----
MIIFAzCCAuugAwIBAgIURKfWVReQ3Nyu+lN9v1h2l8keKi0wDQYJKoZIhvcNAQEL
BQAwETEPMA0GA1UEAwwGUFNUTGFiMB4XDTI0MDkyNDE3MDAzOVoXDTI1MDkyNDE3
MDAzOVowETEPMA0GA1UEAwwGUFNUTGFiMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
MIICCgKCAgEAqJ9m5AEIak0lNEffK4IMIRTyBK3N6wvEbLLRX6oOGmD+642U3V6v
2aoyOqLwE9Df2CZFL4QY7zv6T5gipy4XJSGbg0+Kc5lt9abP9KtahsjR/0RbpuqR
V4rOOaGFdza2ZVoSAh7XZpER2omdRgBpnuAbCZP/PY6AgnTQ8JxZVTHNcjAteSJB
gO27IuCMJgzxg/VS2BkdYSjg6EnANrZwGBpW7oD3k1YH4MTWdC8L5k+oVCLMeKN7
SM47Hui1BD2V7nUAxQT6+RgPMbtuOw6sdfss7bBEeteu9pFWeTpuO4ABX3NpuDC2
5TIF1vPAeTDz8frZPJVqMoUAiCB21VRYxQfTd+EbAzRUguDmve3B07vbtmqZhOb4
Tn/BiAFjfkCkm+JfTXAPgKHZ7FQPsgkJ86brMeqsCZxkEVaKv1pZJi4U7/VOHSog
ZOE5fFDgEIaNVNqaLsWYP+rFIrjjFts5GXsF7EcLIhClsuxktd35jI7yeCNqQYbD
RzFRaTIv6mcZqi/CO/o0cN00DPSeEo/gb+BXQCp06F5nZnhd36LTIZ+9IrdIzGQ5
b9Q0VD/ABojwx9QhrLVGP/HepEaI6H5zpG6ljjbeLfSNej83lXl1S1ZS2bR4iVUC
57DBbEfGvwfZfRrOr6Ek+E00bh95UMOBM+IxkATkovAXi3ifgh+VADUCAwEAAaNT
MFEwHQYDVR0OBBYEFA9nXnk3l4J10rKfANy1i+qcEdl8MB8GA1UdIwQYMBaAFA9n
Xnk3l4J10rKfANy1i+qcEdl8MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEL
BQADggIBACdVMvdw+gKYKYwXIOUP/Ok85kUK+cCbiDgQaqGghJgHoQF67ZgYMHoI
VJfgUHpowqtsI0OI/pVWp1HuRS07SJf99bSO/Xb07E7zRizw+4D7gWu2Jn8unu8B
rX9Z8y/EA4Y2Hqqv6q3IZcYyXoXZLTSTIaatS4WT7Vy2jEtCcgRVljanr6zM/Dxh
WbMRFo15JaGCIP8PjZaQY4bjVf1DC826oWytN8pBQTLb/1kcZhSwJCST1ocEGe8i
Zv4zBDVZj1XgGSzy9cuL24k+SCwgS+6eAFHtcyr8zeME02oH8BSf1PUlvjle4lYT
4YFJeRb0utUakj4nMu8jaDArxosmlC37k1OthHU07JdEtJ47uaN3f+g4UdAF910f
LliV7k8mXLlTox8NVqulE3hRBed/ViW3xdmPcjpflcOUK49ezmSFVsQeh3N8lKCs
rybm1AtzXmIwkHoh0RiI3o0Sq2xdsBjCpkJUazfaOcGdNLggzXMxHMs/8X3mgsoi
1ySBVil9t97ebGVbgNjPWApKeRoUoK4Dtsb6pX2FHXYjCTfPPUYQwk1+G26eN8ew
9w1IarXXJSoNcBS9d4sKbDhja/tqfqhQHte2dcC/9NIh7nzmO5mnrK4YuvEyuks4
WdCKMnEEqiXvBPPdKWi6os0P+pf/WcgizR0Mp0WrjsFs7rQsuVP8
-----END CERTIFICATE-----
8 changes: 8 additions & 0 deletions tests/dh.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-----BEGIN DH PARAMETERS-----
MIIBCAKCAQEAtKA6JjjSRc7tnK0njo4H+sB4/yX2suGLK7uv+WvgZv04/x9uxybI
SFa34eqBd9iBelwE+rOEWe/g0hcQpE0p+T69S5eeBoH52YSuiTD9k+F03/9MTfVM
H5wV7ORe9Z8u+whsEEKev7GnSReHxa1+l7LIuoxVA7omns2yxeNZpB627LKcjZoc
BcRi07ECo0FKxM4N41P98fPgpCsMPUJ4hb9iO3geJ1y8Aw5AwcSATAKOZASZGMwL
6DRX1EFyODIBDeXJglW8ERvm328xFsU4mejbLJBhyOGZXKMrjPealZWO3rWH8fT0
lEjAtyVyLXbHSCyEwSIxw9nh+37m8i87ZwIBAg==
-----END DH PARAMETERS-----
52 changes: 52 additions & 0 deletions tests/key.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
-----BEGIN PRIVATE KEY-----
MIIJQwIBADANBgkqhkiG9w0BAQEFAASCCS0wggkpAgEAAoICAQCon2bkAQhqTSU0
R98rggwhFPIErc3rC8RsstFfqg4aYP7rjZTdXq/ZqjI6ovAT0N/YJkUvhBjvO/pP
mCKnLhclIZuDT4pzmW31ps/0q1qGyNH/RFum6pFXis45oYV3NrZlWhICHtdmkRHa
iZ1GAGme4BsJk/89joCCdNDwnFlVMc1yMC15IkGA7bsi4IwmDPGD9VLYGR1hKODo
ScA2tnAYGlbugPeTVgfgxNZ0LwvmT6hUIsx4o3tIzjse6LUEPZXudQDFBPr5GA8x
u247Dqx1+yztsER61672kVZ5Om47gAFfc2m4MLblMgXW88B5MPPx+tk8lWoyhQCI
IHbVVFjFB9N34RsDNFSC4Oa97cHTu9u2apmE5vhOf8GIAWN+QKSb4l9NcA+Aodns
VA+yCQnzpusx6qwJnGQRVoq/WlkmLhTv9U4dKiBk4Tl8UOAQho1U2pouxZg/6sUi
uOMW2zkZewXsRwsiEKWy7GS13fmMjvJ4I2pBhsNHMVFpMi/qZxmqL8I7+jRw3TQM
9J4Sj+Bv4FdAKnToXmdmeF3fotMhn70it0jMZDlv1DRUP8AGiPDH1CGstUY/8d6k
RojofnOkbqWONt4t9I16PzeVeXVLVlLZtHiJVQL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g0sEFcycdtgimwUWqTlGeBUU71UznBEq/+rQ8iBu0lAJz+FM8GbgvtVD5YSiSq1e
Q/kCggEBAL7FNL6OaHlQPKFyraN/aYtckZHwDVkU59UnTA9HGCIDZ6oNrxIVa09L
uN8R3pvsHI0PDWT3w7K9P9hv4R7P9KV+qlLWsfx/yKLWYJaULI+T+cF4TAK2qyeX
DTJdzNZx8jwIvMziu+tO6t3oKuLB2l7ci0QGi5l9PKnVa85Tnn6gmRPAFu17E883
KqcWqR7CdGLu6BzBrILbizV5iB7Xm3CRYBiSmBHB2xBoKNzR63P2GgZSr3IeN0LV
meciBzU4zKX3vwC7m1XBNfdHuz0iP3xM+HfT5Pz/TxIT2/AWpCimghxL8iCbA/WQ
cdhUAVELcnd3Vl9prJ7okBpJ58BZ7io=
-----END PRIVATE KEY-----
4 changes: 4 additions & 0 deletions tests/test_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ void test_rest_server()
{
test_server server;

#ifdef ENABLE_SSL
server.load_certificate("cert.pem", "key.pem");
#endif

server.add_route(network::verb::Get, "/", [](network::request &req)
{ return std::make_unique<network::html_response>("<html><body><h1>Hello, World!</h1></body></html>"); });
server.add_route(network::verb::Get, "/json", [](network::request &req)
Expand Down

0 comments on commit 0bfbd12

Please sign in to comment.