Exemplo n.º 1
0
 public bool CreateRootCertificate()
 {
     try
     {
         lock (typeof(CertificateConfiguration))
         {
             var algorithm          = CertificateConfiguration.RootCertificateAlgorithm;
             var signatureAlgorithm = CertificateConfiguration.RootCertificateHashAlgorithm;
             var keySize            = CertificateConfiguration.RootRsaKeySize;
             var keyName            = $"{FIDDLER_ROOT_PRIVATE_KEY_NAME}_{algorithm}_{keySize}_{_keyProviderEngine.Name};";
             using (var key = PrivateKey.CreateNew(_keyProviderEngine, keyName, algorithm, KeyUsage.Signature, overwrite: true, keySize: keySize))
             {
                 _root = _generator.GenerateCertificateAuthority(key, new X500DistinguishedName(FIDDLER_ROOT_DN), signatureAlgorithm);
                 return(true);
             }
         }
     }
     catch
     {
         return(false);
     }
 }