c# Get a certificate from a container and set a pin / password programmatically


        public static X509Certificate2 GetCertStorePass(string pin, X509Certificate2 certificate2)
        {
            var provider = (Gost3410CryptoServiceProvider)certificate2.PrivateKey;
            var secure = new System.Security.SecureString();

            foreach (char charPass in pin)
                secure.AppendChar(charPass);
            provider.SetContainerPassword(secure);

            return provider.ContainerCertificate;
        }

No comments:

Post a Comment