c# : How can I create a certificate with key size of 168 using CERTENROLLLib.CX509PrivateKey?

0

I am working with EDI - AS2. So I have to create a PrivateKey certificate (.pfx) and a PublicKey certificate (.cer). Here I sign my message with my PrivateKey certificate (.pfx) and share the PublicKey certificate (.cer) with my trading partner, so that they can verify the signature.

I have written the code to generate test PublicKey certificate (*.pfx). Following is the part of the code where I set properties of private key:

// create a new private key for the certificate
CX509PrivateKey privateKey = new CX509PrivateKey();
privateKey.ProviderName = "Microsoft Enhanced RSA and AES Cryptographic Provider";
privateKey.MachineContext = true;
privateKey.Length = 1024;
privateKey.KeySpec = X509KeySpec.XCN_AT_KEYEXCHANGE;
privateKey.ExportPolicy = X509PrivateKeyExportFlags.XCN_NCRYPT_ALLOW_PLAINTEXT_EXPORT_FLAG;
privateKey.Create();

above code is working fine when I use privateKey.Length = 1024 or 512. but out trading partner want us to create certificate with key size of 168 with 3DES and SHA1

Whenever I give privateKey.Length = 168 I get following error:

CertEnroll::CX509PrivateKey::Create: Invalid flags specified. 0x80090009 (-2146893815)

I am not able to figure out what change I need to do here to make it work.

Please help,

Thanks

certificate
ssl-certificate
x509certificate
public-key-encryption
signing
asked on Stack Overflow Nov 16, 2018 by Yash

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0