-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added SSL support so that jennet can now listen on SSL directly.
- Loading branch information
Showing
5 changed files
with
170 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIDLzCCAhegAwIBAgIJAI/o78XcM9NqMA0GCSqGSIb3DQEBBQUAMBkxFzAVBgNV | ||
BAoTDkZha2UgQXV0aG9yaXR5MB4XDTE1MDQxMTE3NTAwOVoXDTI1MDQwODE3NTAw | ||
OVowGTEXMBUGA1UEChMORmFrZSBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUA | ||
A4IBDwAwggEKAoIBAQDMy0Xuax1Ej1iCOemYdiLwaJ/B8UsCH2ztJVPHyw6HSxwa | ||
WNariJ/d24QLuF9YFx7Xq2oEJK7WJ+zQfnn+jnlQWKfDBFSagreSmOIKRYYkKya3 | ||
JwqluKsXcqxXz//0PkL6gfRNrCsbPUVujTP3Ple5eRK1ilOxc0KaJwtRdYVEPWcU | ||
rv0CvuU7qDKMzBh2Lt3tPC8J6VNqvK5bsLBdhcxFU+OjL65VEGjIc33pHMGkQitl | ||
MpsFolqXYvMt/JPNdf3trPEg8eGHeK9+7AxmaRo4WLaFsYyV5Etwa8ox+p3gGL/I | ||
OpE2PDC1SqJ2HdnLgXK1I/LGRlrNQssfew/rfqdZAgMBAAGjejB4MB0GA1UdDgQW | ||
BBTUVbUqQanwnb1TzSj3VVOXHkPWsDBJBgNVHSMEQjBAgBTUVbUqQanwnb1TzSj3 | ||
VVOXHkPWsKEdpBswGTEXMBUGA1UEChMORmFrZSBBdXRob3JpdHmCCQCP6O/F3DPT | ||
ajAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4IBAQBlCZDD231UlS2FGOLK | ||
yesxakCcCxwuqw6rbldj0zCNNRqlZ8lPDrbbr2ECUBKj6kYVJfU93YaYVYSmSTaB | ||
41/GCfBWdNfPdP4q2kqpmKR5bCeiGYpFNajPLXTpmRvmIQ6NT1u86krIPYxle/02 | ||
DgYatXMGanzcUCwrfSnkqZbyXBKRAxbhyJnLmkJ6HqIm5vs6hDw2KdtgwRw6koFJ | ||
+0unhRHDKjZgFuCveaFFzFFkf4tlGmei3ykR3KTLxY3f1+GPunqD7HgebrE/vLP5 | ||
Bgc1g/KSVGuyqKt9eCnSUlJypbPbKpPjnUrtx00HChpfnKpqiAgHFuZhaxBGUBZD | ||
BccR | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIIEowIBAAKCAQEAzMtF7msdRI9YgjnpmHYi8GifwfFLAh9s7SVTx8sOh0scGljW | ||
q4if3duEC7hfWBce16tqBCSu1ifs0H55/o55UFinwwRUmoK3kpjiCkWGJCsmtycK | ||
pbirF3KsV8//9D5C+oH0TawrGz1Fbo0z9z5XuXkStYpTsXNCmicLUXWFRD1nFK79 | ||
Ar7lO6gyjMwYdi7d7TwvCelTaryuW7CwXYXMRVPjoy+uVRBoyHN96RzBpEIrZTKb | ||
BaJal2LzLfyTzXX97azxIPHhh3ivfuwMZmkaOFi2hbGMleRLcGvKMfqd4Bi/yDqR | ||
NjwwtUqidh3Zy4FytSPyxkZazULLH3sP636nWQIDAQABAoIBADvxuAt8gPmjd8XO | ||
i8ibs8ho53JOXaVGa4zSoz5U+nCxlI1FubhF6n13FqS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OZ9PLp3wXL+TaidTMmU7Fob5spyQe0gn | ||
LqVIyGFYoRbW57pLgSEXRh+Zqw1AAKmMYoc3/pKM60rgOQxMXEemFAJ8zuDQ5L6y | ||
1dR3ak4ueRcSFpa6x8/STsgIuL38HMNXhStsJB9whHAFB3U6Wo2/ | ||
-----END RSA PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use "net" | ||
use "files" | ||
use "net_ssl" | ||
use "http_server" | ||
use "../../jennet" | ||
|
||
actor Main | ||
new create(env: Env) => | ||
let tcplauth: TCPListenAuth = TCPListenAuth(env.root) | ||
let fileauth: FileAuth = FileAuth(env.root) | ||
|
||
try | ||
let sslctx: SSLContext = | ||
try | ||
recover | ||
SSLContext | ||
.>set_cert( | ||
FilePath(fileauth, "cert.pem"), | ||
FilePath(fileauth, "key.pem") | ||
)? | ||
end | ||
else | ||
env.err.print("Unable to configure SSL") | ||
error | ||
end | ||
|
||
let server = | ||
Jennet(tcplauth, env.out) | ||
.> get("/", H) | ||
.> sslctx(sslctx) | ||
.serve(ServerConfig(where port' = "8443")) | ||
|
||
if server is None then | ||
env.err.print("bad routes!") | ||
error | ||
end | ||
else | ||
env.err.print("Server unable to start") | ||
end | ||
|
||
primitive H is RequestHandler | ||
fun apply(ctx: Context): Context iso^ => | ||
let body = "Hello".array() | ||
ctx.respond( | ||
StatusResponse( | ||
StatusOK, | ||
[("Content-Length", body.size().string())] | ||
), | ||
body | ||
) | ||
consume ctx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters