Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: convert C# to perl script

by Corion (Patriarch)
on Sep 18, 2018 at 07:58 UTC ( [id://1222569]=note: print w/replies, xml ) Need Help??


in reply to convert C# to perl script

Hello Metilda!

What are your problems with converting the C# code to Perl? Are you looking for the right modules to use? Are you looking for a general approach of converting C# to Perl?

What Perl code have you already written for this problem and how does it fail to do what you need?

Replies are listed 'Best First'.
Re^2: convert C# to perl script
by Metilda (Initiate) on Sep 18, 2018 at 08:12 UTC

    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.

      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.

      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?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1222569]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-24 20:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found