Пример #1
0
        public EnterpriseKey(Uri Uri, String Name, Boolean allowCreateNewServerCert = true)
        {
            this.dnsName = Uri.Host;
            this.name    = Name;

            //A senha dos certificados é o hash da URI da empresa
            System.Security.Cryptography.SHA1Managed sha = new System.Security.Cryptography.SHA1Managed();
            Byte[] hash = sha.ComputeHash(Encoding.UTF8.GetBytes(this.dnsName));
            key = BitConverter.ToString(hash).Replace("-", "");

            ca = new CertificateAuthority(key);
            if (allowCreateNewServerCert)
            {
                ca.LoadOrCreateCA("IAMServerCertificateRoot.pfx", "IAM Server Certificate Root");
            }
            else
            {
                ca.LoadCA("IAMServerCertificateRoot.pfx");
            }

            if (ca.RootCA == null)
            {
                throw new Exception("Error loading/creating CA Cert");
            }
        }