Comments (1)
using nodejs we match the same result with the code:
import fs from "fs";
import { createServer } from "https";
createServer(
{
key: fs.readFileSync("/tmp/server-key.pem"),
cert: fs.readFileSync("/tmp/server-cert.pem"),
ca: fs.readFileSync("/tmp/ca-cert.pem"),
requestCert: true,
rejectUnauthorized: true,
},
(req, res) => {
res.end("pong");
},
).listen(1234);
cirospaciari@Ciros-MBP ~ % curl -v -k https://127.0.0.1:1234
* Trying 127.0.0.1:1234...
* Connected to 127.0.0.1 (127.0.0.1) port 1234
* ALPN: curl offers h2,http/1.1
* (304) (OUT), TLS handshake, Client hello (1):
* (304) (IN), TLS handshake, Server hello (2):
* (304) (IN), TLS handshake, Unknown (8):
* (304) (IN), TLS handshake, Request CERT (13):
* (304) (IN), TLS handshake, Certificate (11):
* (304) (IN), TLS handshake, CERT verify (15):
* (304) (IN), TLS handshake, Finished (20):
* (304) (OUT), TLS handshake, Certificate (11):
* (304) (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / AEAD-CHACHA20-POLY1305-SHA256 / [blank] / UNDEF
* ALPN: server did not agree on a protocol. Uses default.
* Server certificate:
* subject: CN=127.0.0.1
* start date: Jul 9 00:24:26 2024 GMT
* expire date: Jun 1 00:24:26 2161 GMT
* issuer: CN=127.0.0.1
* SSL certificate verify result: self signed certificate (18), continuing anyway.
* using HTTP/1.x
> GET / HTTP/1.1
> Host: 127.0.0.1:1234
> User-Agent: curl/8.6.0
> Accept: */*
>
* LibreSSL SSL_read: LibreSSL/3.3.6: error:1404C45C:SSL routines:ST_OK:reason(1116), errno 0
* Closing connection
curl: (56) LibreSSL SSL_read: LibreSSL/3.3.6: error:1404C45C:SSL routines:ST_OK:reason(1116), errno 0
If we use rejectUnauthorized: false
at the server we will not auto close the connection:
const s = Bun.serve({
fetch: () => new Response("pong"),
port: 1234,
tls: {
key: Bun.file("/tmp/server-key.pem"),
cert: Bun.file("/tmp/server-cert.pem"),
ca: Bun.file("/tmp/ca-cert.pem"),
rejectUnauthorized: false,
},
});
nodejs equivalent:
import fs from "fs";
import { createServer } from "https";
createServer(
{
key: fs.readFileSync("/tmp/server-key.pem"),
cert: fs.readFileSync("/tmp/server-cert.pem"),
ca: fs.readFileSync("/tmp/ca-cert.pem"),
requestCert: true,
rejectUnauthorized: false,
},
(req, res) => {
res.end("pong");
},
).listen(1234);
cirospaciari@Ciros-MBP ~ % curl -v -k https://127.0.0.1:1234
* Trying 127.0.0.1:1234...
* Connected to 127.0.0.1 (127.0.0.1) port 1234
* ALPN: curl offers h2,http/1.1
* (304) (OUT), TLS handshake, Client hello (1):
* (304) (IN), TLS handshake, Server hello (2):
* (304) (IN), TLS handshake, Unknown (8):
* (304) (IN), TLS handshake, Request CERT (13):
* (304) (IN), TLS handshake, Certificate (11):
* (304) (IN), TLS handshake, CERT verify (15):
* (304) (IN), TLS handshake, Finished (20):
* (304) (OUT), TLS handshake, Certificate (11):
* (304) (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / AEAD-CHACHA20-POLY1305-SHA256 / [blank] / UNDEF
* ALPN: server did not agree on a protocol. Uses default.
* Server certificate:
* subject: CN=127.0.0.1
* start date: Jul 9 00:24:26 2024 GMT
* expire date: Jun 1 00:24:26 2161 GMT
* issuer: CN=127.0.0.1
* SSL certificate verify result: self signed certificate (18), continuing anyway.
* using HTTP/1.x
> GET / HTTP/1.1
> Host: 127.0.0.1:1234
> User-Agent: curl/8.6.0
> Accept: */*
>
< HTTP/1.1 200 OK
< content-type: text/plain;charset=utf-8
< Date: Tue, 09 Jul 2024 00:41:25 GMT
< Content-Length: 4
<
* Connection #0 to host 127.0.0.1 left intact
pong%
from bun.
Related Issues (20)
- node-tar can't extract files HOT 2
- url is defined on globalThis. url is far too common a variable name
- Udp Socket sending binary data by buffer length
- (windows) bun panic when simply add deps
- fetch doesn't forward bodies correctly
- Bun Crashed HOT 1
- Bun.serve ERR_INVALID_ARG_TYPE on Linux x64 baseline HOT 4
- Child process interaction becomes super slow
- segfault
- bun does not run in docker in kvm HOT 7
- Bun install not detecting local pakages in workspace.
- output to arm64 fail
- `require`ing a module is sharing the current global scope with said module
- panic(main thread): incorrect alignment (Using zeromq) HOT 2
- Issue with node-ipc
- VSCode throws type error when instantiating express
- Crash
- Stacktrace not working on canary
- [VS Code Extension]: Add support for running scripts from subfolders
- hono serveStatic panic / hard crash (without bun.report) if with an async middleware (redis in this case)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bun.