public static void CopyFrom_ReadSerialNumberFirst() { X509AuthorityKeyIdentifierExtension ext = new X509AuthorityKeyIdentifierExtension(); ext.CopyFrom(GetFullyValuedExtension()); ReadOnlyMemory <byte>?serial = ext.SerialNumber; Assert.Equal("00EE7B", serial.GetValueOrDefault().ByteArrayToHex()); }
public static void CopyFrom_ReadKeyIdentifierFirst() { X509AuthorityKeyIdentifierExtension ext = new X509AuthorityKeyIdentifierExtension(); ext.CopyFrom(GetFullyValuedExtension()); ReadOnlyMemory <byte>?keyIdentifier = ext.KeyIdentifier; Assert.Equal("000000000000000880", keyIdentifier.GetValueOrDefault().ByteArrayToHex()); }
public static void CopyFrom_ReadNamedIssuerFirst() { X509AuthorityKeyIdentifierExtension ext = new X509AuthorityKeyIdentifierExtension(); ext.CopyFrom(GetFullyValuedExtension()); X500DistinguishedName namedIssuer = ext.NamedIssuer; Assert.NotNull(namedIssuer); Assert.Equal("CN=Hello", namedIssuer.Name); }
public static void CopyFrom_ReadRawIssuerFirst() { X509AuthorityKeyIdentifierExtension ext = new X509AuthorityKeyIdentifierExtension(); ext.CopyFrom(GetFullyValuedExtension()); ReadOnlyMemory <byte>?rawIssuer = ext.RawIssuer; Assert.Equal( "A114A4123010310E300C0603550403130548656C6C6F", rawIssuer.GetValueOrDefault().ByteArrayToHex()); }
public static void DecodeInvalid() { byte[] invalidEncoding = { 0x05, 0x00 }; Assert.Throws <CryptographicException>( () => new X509AuthorityKeyIdentifierExtension(invalidEncoding)); Assert.Throws <CryptographicException>( () => new X509AuthorityKeyIdentifierExtension(new ReadOnlySpan <byte>(invalidEncoding))); X509Extension untypedExt = new X509Extension("0.1", invalidEncoding, critical: true); X509AuthorityKeyIdentifierExtension ext = new X509AuthorityKeyIdentifierExtension(); ext.CopyFrom(untypedExt); Assert.True(ext.Critical, "ext.Critical"); Assert.Equal("0.1", ext.Oid.Value); Assert.Throws <CryptographicException>(() => ext.KeyIdentifier); Assert.Throws <CryptographicException>(() => ext.SerialNumber); Assert.Throws <CryptographicException>(() => ext.NamedIssuer); Assert.Throws <CryptographicException>(() => ext.RawIssuer); }