27 lines
720 B
Dart
27 lines
720 B
Dart
import 'dart:io';
|
|
|
|
String certificateChain = 'server_chain.pem';
|
|
String serverKey = 'server_key.pem';
|
|
|
|
Future main() async {
|
|
var serverContext = SecurityContext();
|
|
serverContext
|
|
..useCertificateChain(certificateChain)
|
|
..usePrivateKey(serverKey, password: 'dartdart');
|
|
|
|
var server = await HttpServer.bindSecure(
|
|
'0.0.0.0',
|
|
8443,
|
|
serverContext,
|
|
);
|
|
print('[INFO] Listening on localhost:${server.port} for HTTPS requests');
|
|
await for (HttpRequest request in server) {
|
|
print('[INFO] Got request for ${request.uri.path}');
|
|
request.response
|
|
..statusCode = 200
|
|
..headers.add("content-type", "text/plain; charset=utf-8")
|
|
..write('Hello, world!\n')
|
|
..close();
|
|
}
|
|
}
|