Assert.Equal(contentType, blobType);
}
+ [Fact]
+ public static void TestThrowsWhenGivenInvalidContent()
+ {
+ byte[] blob = new byte[] { 0x00, 0xFF, 0x00, 0xFF };
+ Assert.ThrowsAny<CryptographicException>(() => X509Certificate2.GetCertContentType(blob));
+ }
+
public static IEnumerable<object[]> GetContentBlobsWithType()
{
return new[]
new object[] { "EmptyPfx", TestData.EmptyPfx, X509ContentType.Pkcs12 },
new object[] { "MultiPrivatePfx", TestData.MultiPrivateKeyPfx, X509ContentType.Pkcs12 },
new object[] { "ChainPfx", TestData.ChainPfxBytes, X509ContentType.Pkcs12 },
+ new object[] { "ConcatenatedPem", TestData.ConcatenatedPemFile, X509ContentType.Cert }
};
}
}
"39366d5a59590a734f65735a513d3d0a2d2d2d2d2d454e442043455254494649" +
"434154452d2d2d2d2d0a").HexToByteArray();
+ internal static byte[] ConcatenatedPemFile = ByteUtils.AsciiBytes(
+ @"-----BEGIN CERTIFICATE-----
+MIIFcDCCBFigAwIBAgIQB6krbZc11OZ5l2/FnU3CpTANBgkqhkiG9w0BAQsFADBG
+MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRUwEwYDVQQLEwxTZXJ2ZXIg
+Q0EgMUIxDzANBgNVBAMTBkFtYXpvbjAeFw0xODA2MTMwMDAwMDBaFw0xOTA2MTMx
+MjAwMDBaMB4xHDAaBgNVBAMTE2VjaG8tYXBpLmFtYXpvbi5jb20wggEiMA0GCSqG
+SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCFTKdiYc8w7wt59nCfHzpT9xy8mDk8spkC
+ECPzIC1Qim9T7dSRsT7tcUJIOHMPXxrlxyySSK1qB7LLdoDFuhW/CtUdD4c6t73y
+ryNHQzhPZ7fQvb8jMWf5VWPTNsS1FBAKZdTe6n0pjIAS4nypxfF+eXMaQrHiH4Ib
+iV+aZP7Men40j/YucEeii8ukmfmlQ8L351BUZmCD1FZlXD+fLb5YgbZjC+c6TB0K
+WI2oe3qK0zFKGigaFvNBoZl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
+AQH/AgEAMA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUWaRmBlKge5WSPKOUByeW
+dFv5PdAwHwYDVR0jBBgwFoAUhBjMhTTsvAyUlC4IWZzHshBOCggwewYIKwYBBQUH
+AQEEbzBtMC8GCCsGAQUFBzABhiNodHRwOi8vb2NzcC5yb290Y2ExLmFtYXpvbnRy
+dXN0LmNvbTA6BggrBgEFBQcwAoYuaHR0cDovL2NydC5yb290Y2ExLmFtYXpvbnRy
+dXN0LmNvbS9yb290Y2ExLmNlcjA/BgNVHR8EODA2MDSgMqAwhi5odHRwOi8vY3Js
+LnJvb3RjYTEuYW1hem9udHJ1c3QuY29tL3Jvb3RjYTEuY3JsMBMGA1UdIAQMMAow
+CAYGZ4EMAQIBMA0GCSqGSIb3DQEBCwUAA4IBAQCFkr41u3nPo4FCHOTjY3NTOVI1
+59Gt/a6ZiqyJEi+752+a1U5y6iAwYfmXss2lJwJFqMp2PphKg5625kXg8kP2CN5t
+6G7bMQcT8C8xDZNtYTd7WPD8UZiRKAJPBXa30/AbwuZe0GaFEQ8ugcYQgSn+IGBI
+8/LwhBNTZTUVEWuCUUBVV18YtbAiPq3yXqMB48Oz+ctBWuZSkbvkNodPLamkB2g1
+upRyzQ7qDn1X8nn8N8V7YJ6y68AtkHcNSRAnpTitxBKjtKPISLMVCx7i4hncxHZS
+yLyKQXhw2W2Xs0qLeC1etA+jTGDK4UfLeC0SF7FSi8o5LL21L8IzApar2pR/
+-----END CERTIFICATE-----"
+ );
+
internal static DSAParameters GetDSA1024Params()
{
DSAParameters p = new DSAParameters();