in reply to Re: convert C# to perl script
in thread convert C# to perl script

Hi, I have installed REST::Client and Crypt::X509 modules.

my $url = "https://my rest services url"; my $jsonBody = '{ json details }'; my $client = REST::Client->new(); $client->addHeader('Content-Type', 'application/json'); $client->addHeader('charset', 'UTF-8'); $client->addHeader('Accept', 'application/json'); $client->addHeader('Authorization', 'Basic xxxxxxxxxxxxxxxxxxxxxxx'); $client->PUT($url, $jsonBody);
The above script is working fine without using ssl certificate. Now i want to include ssl certificate. I have my pfx file and want to create certificate object using X509Certificate. Need your help to convert that C# code to perl.

Replies are listed 'Best First'.
Re^3: convert C# to perl script (PKCS12 to PEM)
by hippo (Archbishop) on Sep 18, 2018 at 08:21 UTC
    I have my pfx file and want to create certificate

    You could do this separately using a CLI utility such as openssl but if you want to do that inside perl, take a look at Crypt::OpenSSL::PKCS12 which shows in the synopsis how to achieve this.

Re^3: convert C# to perl script
by Corion (Patriarch) on Sep 18, 2018 at 08:14 UTC

    Looking through the documentation for Rest::Client, I find these two lines:

    #X509 client authentication $client->setCert('/path/to/ssl.crt'); $client->setKey('/path/to/ssl.key');

    Have you tried adding your certificate and key file that way? How does it fail?