multi_domain_secure_server 1.0.9 multi_domain_secure_server: ^1.0.9 copied to clipboard
A SecureServerSocket that supports multiple domains with dynamic SecurityContext resolution.
multi_domain_secure_server #
multi_domain_secure_server
is a SecureServerSocket that supports multiple domains with dynamic SecurityContext resolution.
Usage #
import 'dart:io';
import 'package:multi_domain_secure_server/multi_domain_secure_server.dart';
/// Example of a [MultiDomainSecureServer].
///
/// You can test it (on port 8443) with:
/// ```bash
/// curl -v -k --resolve example.com:8443:127.0.0.1 https://example.com:8443/foo
/// ```
void main() async {
// Define a `SecurityContext` for each hostname:
var hostnamesSecurityContexts = {
'example.com': SecurityContext().configure(
certificateChainFile: '/path/to/example.com/cert.pem',
privateKeyFile: '/path/to/example.com/private-key.pem',
),
'foo.com': SecurityContext().configure(
certificateChainFile: '/path/to/foo.com/cert.pem',
privateKeyFile: '/path/to/foo.com/private-key.pem',
),
};
// Create the Secure Server at port 8443:
var server = await MultiDomainSecureServer.bind(
InternetAddress.anyIPv4,
8443,
securityContextResolver: (hostname) {
print('-- Resolving `SecurityContext` for hostname: $hostname');
return hostnamesSecurityContexts[hostname];
},
);
print('** Secure Server running: $server');
server.onAccept.listen((acceptedSocket) {
print(
'-- Accepted Socket: ${acceptedSocket.remoteAddress.address}:${acceptedSocket.remotePort}');
});
}
Source #
The official source code is hosted @ GitHub:
Features and bugs #
Please file feature requests and bugs at the issue tracker.
Contribution #
Any help from the open-source community is always welcome and needed:
- Found an issue?
- Please fill a bug report with details.
- Wish a feature?
- Open a feature request with use cases.
- Are you using and liking the project?
- Promote the project: create an article, do a post or make a donation.
- Are you a developer?
- Fix a bug and send a pull request.
- Implement a new feature.
- Improve the Unit Tests.
- Have you already helped in any way?
- Many thanks from me, the contributors and everybody that uses this project!
If you donate 1 hour of your time, you can contribute a lot, because others will do the same, just be part and start with your 1 hour.
Author #
Graciliano M. Passos: gmpassos@GitHub.
Sponsor #
Don't be shy, show some love, and become our GitHub Sponsor. Your support means the world to us, and it keeps the code caffeinated! ☕✨
Thanks a million! 🚀😄