public void Create_WhenCertificateNull_Throws()
        {
            var exception = Assert.Throws <ArgumentNullException>(
                () => EssCertIdV2.Create(certificate: null, hashAlgorithmName: HashAlgorithmName.SHA256));

            Assert.Equal("certificate", exception.ParamName);
        }
        public void Create_WithUnknownHashAlgorithmName_Throws()
        {
            using (var certificate = _fixture.GetDefaultCertificate())
            {
                var exception = Assert.Throws <ArgumentException>(
                    () => EssCertIdV2.Create(certificate, HashAlgorithmName.Unknown));

                Assert.Equal("hashAlgorithmName", exception.ParamName);
            }
        }
        public static SigningCertificateV2 Create(X509Certificate2 certificate, HashAlgorithmName hashAlgorithmName)
        {
            if (certificate == null)
            {
                throw new ArgumentNullException(nameof(certificate));
            }

            var essCertIdV2 = EssCertIdV2.Create(certificate, hashAlgorithmName);

            return(new SigningCertificateV2(new[] { essCertIdV2 }, policies: null));
        }
        public void Create_WithSha512_ReturnsEssCertIdV2()
        {
            var hashAlgorithmName = HashAlgorithmName.SHA512;

            using (var certificate = _fixture.GetDefaultCertificate())
            {
                var essCertIdV2 = EssCertIdV2.Create(certificate, hashAlgorithmName);

                Assert.Equal(SigningTestUtility.GetHash(certificate, hashAlgorithmName), essCertIdV2.CertificateHash);
                Assert.Equal(Oids.Sha512, essCertIdV2.HashAlgorithm.Algorithm.Value);
                Assert.Equal(1, essCertIdV2.IssuerSerial.GeneralNames.Count);
                Assert.Equal(certificate.IssuerName.Name, essCertIdV2.IssuerSerial.GeneralNames[0].DirectoryName.Name);
                SigningTestUtility.VerifySerialNumber(certificate, essCertIdV2.IssuerSerial);
            }
        }