public static string CreateCARoot() { var caRoot = Cert2.CreateCertificateAuthorityCertificate("MyRootCA"); var add = Cert2.AddCertToStore(caRoot, StoreName.Root, StoreLocation.LocalMachine); byte[] caRootPfx = caRoot.Export(X509ContentType.Pfx, PIN); File.WriteAllBytes(CARootPfx, caRootPfx); byte[] caRootCer = caRoot.Export(X509ContentType.Cert, PIN); File.WriteAllBytes(CARootCer, caRootCer); return(CARootPfx); }
public static void RootVerifyUserCA() { try { X509Certificate2 userCert2 = new X509Certificate2(CAUserPfx, PIN, X509KeyStorageFlags.Exportable); X509Certificate userCert = DotNetUtilities.FromX509Certificate(userCert2); userCert2.p var userKeyPair = userCert.GetPublicKey(); //var publicKey = userCert2.PublicKey; X509Certificate2 rootCert2 = new X509Certificate2(CARootPfx, PIN, X509KeyStorageFlags.Exportable); //var rootKeyPair = Cert2.ReadPrivateKey(rootCert2); var add = Cert2.AddCertToStore(rootCert2, StoreName.Root, StoreLocation.LocalMachine); var rootCert = DotNetUtilities.FromX509Certificate(userCert2); var rootKeyPair = rootCert.GetPublicKey(); //rootCert.Verify(userKeyPair); var a = Cert2.VerifySha2(rootCert2, userCert.GetEncoded(), userCert.GetSignature()); } catch (Exception ex) { //throw; } }