NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: Niels Larsen on May 07, 2025, 10:19:40 PM

Title: Webclient with certificat
Post by: Niels Larsen on May 07, 2025, 10:19:40 PM
Hi

I'm a little rusty with certificates so I need some help.
The task is to connect to an api via an NT webclient.
I have a pfx file and a password.
Works fine in Postman, so now I just need to get it to work in NT.
How do I insert the reference to the certificate and password?

Regards Niels
Title: Re: Webclient with certificat
Post by: Bruce on May 08, 2025, 06:03:43 PM
Not sure if this is helpful - but see NetDemo, NetWebClient, "Secure HTTPS Options" tab, Client Certificate option.
If you can get it working from there, you'll be golden.

Cheers
Bruce
Title: Re: Webclient with certificat
Post by: Jane on May 08, 2025, 08:44:44 PM
Net demo web client is great for testing.
I don't think you'll be able to make it work with the PFX, though.
A PFX contains both the certificate (with its public key) and your secret private key.  And it's password-protected.

To split apart a PFX for use with NetTalk, use openssl (it's installed automatically with any of your netweb server projects).

When you use openssl, the first private key file you'll get will be password-protected. 
You can also run one more openssl command to produce an unencrypted private key file.

Code: [Select]
Openssl pkcs12 -in MyDomain.pfx -nocerts -out MyDomainEncrypted.key
Openssl rsa -in MyDomainEncrypted.key -out MyUnencryptedDomain.key
Openssl pkcs12 -in MyDomain.pfx -clcerts -nokeys -out MyDomain.crt
Title: Re: Webclient with certificat
Post by: Niels Larsen on May 08, 2025, 11:32:59 PM
You just made my Friday a great day.
You pointed me in the right direction.
When I couldn't get your commands to work (because I didn't realize that your - was converted to a ?) I found the description at https://www.ssl.com/how-to/export-certificates-private-key-from-pkcs12-file-with-openssl/
What I thought was impossible turned out to be very easy.

THANK YOU Jane!!!
Title: Re: Webclient with certificat
Post by: Jane on May 09, 2025, 04:48:09 PM
ACK!
Sorry, Niels.  I thought I had edited those question-marks-that-should-be-dashes.

I pasted text from a PDF I did for a ClarionLive webinar some years back and the rogue question marks blossomed. 

Anyway, I hope you got it working.

Cheers,

Jane