NetTalk Central

Author Topic: Webclient with certificat  (Read 2011 times)

Niels Larsen

  • Sr. Member
  • ****
  • Posts: 456
    • View Profile
    • Email
Webclient with certificat
« 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

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11309
    • View Profile
Re: Webclient with certificat
« Reply #1 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

Jane

  • Sr. Member
  • ****
  • Posts: 399
  • Expert on nothing with opinions on everything.
    • View Profile
    • Email
Re: Webclient with certificat
« Reply #2 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
« Last Edit: May 09, 2025, 04:49:00 PM by Jane »

Niels Larsen

  • Sr. Member
  • ****
  • Posts: 456
    • View Profile
    • Email
Re: Webclient with certificat
« Reply #3 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!!!

Jane

  • Sr. Member
  • ****
  • Posts: 399
  • Expert on nothing with opinions on everything.
    • View Profile
    • Email
Re: Webclient with certificat
« Reply #4 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