[WINDOWS] mongocxx Client cannot parse private key for a TLS connection to mongodb server

Hi, I’m trying to setup a mongocxx connection to a mongodb server with a TLS connection. I’ve gotten mongo-express setup with TLS connections, so I know that the server is configured to allow TLS connections. The driver works as expected if I’m not using TLS, however when I try to enable tls and provide a .pem file, I get this error

 Failed to parse private key. ASN1 bad tag value met.
 (0x8009310B)

Keep in mind I’ve used the same method of generating the .pem file for mongo-express, so I’m surprised the same way doesn’t work for the driver. Any ideas on how to fix this problem?

Hi @Nate_Rearick, this may be related to a known issue loading PKCS#8 private keys on Windows if attempting to use client certs. CDRIVER-4269 tracks this issue and notes a possible workaround by converting the key to PKCS#1:

As a workaround, users can convert PKCS#8 to PKCS#1 for an RSA key:
openssl rsa -in private_key_pkcs8.pem -out private_key_pkcs1.pem