private SOAPEnvelope <SAMLRequestBody> BuildEIDSamlRequest(string pin) { SOAPEnvelope <SAMLRequestBody> samlEnv = null; var orgAuthCertificate = _keyStoreManager.GetOrgAuthCertificate(); using (var discovery = new BeIDCardDiscovery()) { var readers = discovery.GetReaders(); using (var connection = discovery.Connect(readers.First())) { var certificate = connection.GetAuthCertificate(); var idAuthCertificate = new MedikitCertificate(new X509Certificate2(connection.GetAuthCertificate().Export(X509ContentType.Cert)), null); samlEnv = BuildRequest(idAuthCertificate, orgAuthCertificate, (_ => { byte[] hashPayload = null; using (var sha = new SHA1CryptoServiceProvider()) { hashPayload = sha.ComputeHash(_); } return(connection.SignWithAuthenticationCertificate(hashPayload, BeIDDigest.Sha1, pin)); })); } } return(samlEnv); }
public static void Main(string[] args) { using (var discovery = new BeIDCardDiscovery()) { var readers = discovery.GetReaders(); using (var connection = discovery.Connect(readers.First())) { var identity = connection.GetIdentity(); var addr = connection.GetAddress(); var sigCertificate = connection.GetSignCertificate(); var authCertificate = connection.GetAuthCertificate(); var rrnCertificate = connection.GetRRNCertificate(); var rootCaCertificate = connection.GetRootCACertificate(); var citizenCaCertificate = connection.GetCitizenCACertificate(); } } }