CertificateExtension.EnhancedKeyUsage method has been added in Rebex Security 2014 R3, which means the code below is no longer needed.
This looks like an omission on our part. We wanted to add a CertificateExtension.EnhancedKeyUsage method (similar to CertificateExtension.KeyUsage), but never actually implemented it, even though we support extended/enhanced key usage extension in other parts of our library.
Fortunately, a workaround for this is not too complicated:
// construct a sequence of a single extended key usage item
// (see http://www.alvestrand.no/objectid/188.8.131.52.html for details)
var oid = new ObjectIdentifier("184.108.40.206.220.127.116.11.2"); //Client Authentication
byte rawOid = oid.ToArray(true);
byte rawOidList = new byte[rawOid.Length + 2];
rawOidList = 0x30; // sequence
rawOidList = (byte)rawOid.Length; // length (OID length should fit into one byte)
// add a non-critical "extended key usage" extension with the raw OID list
csr.CertificateExtensions.Add(new CertificateExtension("18.104.22.168", false, rawOidList));
If you would like to try a beta of our library when we add CertificateExtension.EnhancedKeyUsage method, please let me know. Thanks for bringing this to our attention!