/** * add a given extension field for the standard extensions tag * The value parameter becomes the contents of the octet string associated * with the extension. */ public void AddExtension( string oid, bool critical, byte[] value) { DerObjectIdentifier derOid = new DerObjectIdentifier(oid); extensions[derOid] = new X509Extension(critical, new DerOctetString(value)); extOrdering.Add(derOid); }
/// <sumary>Convert the value of the passed in extension to an object.</sumary> /// <param name="ext">The extension to parse.</param> /// <returns>The object the value string contains.</returns> /// <exception cref="ArgumentException">If conversion is not possible.</exception> public static Asn1Object ConvertValueToObject( X509Extension ext) { try { return Asn1Object.FromByteArray(ext.Value.GetOctets()); } catch (Exception e) { throw new ArgumentException("can't convert extension", e); } }