title: Get the password for x509Certificate C# bouncy castle
body: <p>Hi I use the attached code to create x509certificate with bouncy-castle dll
  how can i get the Certificate password?</p>
  
  <pre><code>private static X509Certificate2 GenerateCertificate(string certName)
      {
          var keypairgen = new RsaKeyPairGenerator();
          keypairgen.Init(new KeyGenerationParameters(new SecureRandom(new CryptoApiRandomGenerator()), 1024));
  
          var keypair = keypairgen.GenerateKeyPair();
  
          var gen = new X509V3CertificateGenerator();
  
          var CN = new X509Name("CN=" + certName);
          var SN = BigInteger.ProbablePrime(120, new Random());
  
          gen.SetSerialNumber(SN);
          gen.SetSubjectDN(CN);
          gen.SetIssuerDN(CN);
          gen.SetNotAfter(DateTime.MaxValue);
          gen.SetNotBefore(DateTime.Now.Subtract(new TimeSpan(7, 0, 0, 0)));
          gen.SetSignatureAlgorithm("MD5WithRSA");
          gen.SetPublicKey(keypair.Public);
  
          var newCert = gen.Generate(keypair.Private);
  
          return new X509Certificate2(DotNetUtilities.ToX509Certificate((Org.BouncyCastle.X509.X509Certificate)newCert));
      }
  </code></pre>