x509 - IdentityServer4: How to load Signing Credential from Cert Store when in Docker -
we have identityserver4-based sts running on windows, signing credential has been installed local computer .pfx under personal > certificates, , .cer under trusted people > certificates. able load signing credential common name follows:
services.addidentityserver() .addsigningcredential("cn=cert_name") ... we wanting run our sts implementation within docker container, , have been running following exception:
unhandled exception: system.platformnotsupportedexception: unix localmachine x509store limited root , certificateauthority stores. @ internal.cryptography.pal.storepal.fromsystemstore(string storename, storelocation storelocation, openflags openflags) @ system.security.cryptography.x509certificates.x509store.open(openflags flags) @ identitymodel.x509certificatesfinder.find(object findvalue, boolean validonly) @ microsoft.extensions.dependencyinjection.identityserverbuilderextensionscrypto.addsigningcredential(iidentityserverbuilder builder, string name, storelocation location, nametype nametype) based on above error message, , source addsigningcredential method we're using here: https://github.com/identityserver/identityserver4/blob/ec17672d27f9bed42f9110d73755170ee9265116/src/identityserver4/configuration/dependencyinjection/builderextensions/crypto.cs#l73, seems apparent our issue identityserver4 looking certificate in local machine's personal ("my") store, however, such store not available within unix environments per error message.
so, i'm curious know if best practice exists loading signing credential identityserver4 in docker containers, if isn't possible load name or fingerprint. option bundle certificate in our application, load filename?
thanks may able offer!
i developing on windows machine , use following code certificate store
x509certificate2 cert = null; x509store certstore = new x509store(storename.my, storelocation.currentuser); certstore.open(openflags.readonly); x509certificate2collection certcollection = certstore.certificates.find( x509findtype.findbythumbprint, "thumbprint", false); if (certcollection.count > 0) { cert = certcollection[0]; log.logger.information($"successfully loaded cert registry: {cert.thumbprint}"); } if (cert == null) // fallback { cert = new x509certificate2(path.combine(_env.contentrootpath, "certificate.pfx"), "password"); //log.logger.information($"falling cert file. loaded: {cert.thumbprint}"); } else { certstore.dispose(); }
Comments
Post a Comment