Open isoos opened 5 years ago
cc @jonasfj @sortie
Maybe if you concatenate the certificates.... You can certainly do multiple hostnames in a single certificate. Regardless, I think this is a pretty advanced feature.
But really, I would recommend terminating TLS before you hit your Dart server.
Any example in how to do build a SecurityContext
with multiple domains?
Or how to concatenate the certificates? I tried some variations here, but I can't make it work.
Also, relevant and useful package on pub.dev, with @gmpassos as the author, which could really use this multi-host binding: https://pub.dev/packages/shelf_letsencrypt
To generate a PKCS12
with multiple domains certificates generated with the same key pair (same private key) and with the password xyz
:
openssl pkcs12 -export \
-inkey /path/to/privkey.pem \
-in /path/to/domain1.com/fullchain.pem -name domain1.com \
-certfile /path/to/domain2.com/fullchain.pem -name domain2.com \
-out /path/to/keystore-multi.pfx -passout pass:xyz
To generate aPKCS12
with multiple domains certificates WITHOUT add a private key and with the password xyz
:
openssl pkcs12 -export \
-nokeys \
-in /path/to/domain1.com/fullchain.pem -name domain1.com \
-certfile /path/to/domain2.com/fullchain.pem -name domain2.com \
-out /path/to/keystore-multi.pfx -passout pass:xyz
The Dart
code to load this:
var password = 'xyz';
var fullchainFile = '/path/to/keystore-multi.pfx';
var privateKeyFile = '/path/to/privkey.pem';
var sc = SecurityContext()
..useCertificateChain(fullchainFile, password: password)
..usePrivateKey(privateKeyFile, password: password);
Note that if you use a private key that won't match the certificates you will get an exception while loading the them.
The only way that I was able to load multiple certificates was using multiple domains certificates generated with the same private key (yes this is allowed).
But this is still not enough, since the SecurityContext
will always respond with the 1st domain in the PKCS12
file!
So the HTTPS
request will work only for the 1st domain in the PKCS12
file.
It seems that the Dart
implementation is not looking for the correct certificate subject (subject=CN = domainX.com
).
@mit-mit @kevmoo We need a task force for this issue. This is very important.
FYI @brianquinlan
Any update on the issue?
@brianquinlan ?
How can I help to push this issue?
Hi, any improvement?
It's all about the selection of the correct certificate (server side) for the requested URL/domain.
?
How can I help to push this issue?
Up. Please, this is extremely important!!
I'm interested in this too
FYI: @kevmoo @brianquinlan
I’ve published a pure Dart solution for this issue:
https://github.com/gmpassos/multi_domain_secure_server
Additionally, there’s an example demonstrating its use with shelf:
https://github.com/gmpassos/multi_domain_secure_server/tree/master/example/shelf_example
Any feedback would be greatly appreciated!
Best regards,
@gmpassos Thank you, this looks interesting and useful! I shall try it out in the coming weeks.
I couldn't find any example, test or documentation on how to create a https server with multiple hostnames (separate certificates for each hosts). Is is supported?