Hello Masters of Perl!

Solved! Special thanks to sundialsvc4

The truth is that i've never touched OpenSSL before so please have this in mind if you think I seem lost when it might be very obvious.

So, I'm gonna implement an integration to a webservice. Usually web services just concatenate parameters to string which is concatenated with a secret key and then this string with be used to create an MD5-hash. In this case the signature require a bit more security, or at least more complex way of making the signature.

The signature is made up by several concatenated parameters and other parameters and then the "tricky" parts come, OpenSSL signing and verification. I've made both the public and private key from the terminal as described in the documentation for the webservice. This is how far i made it. In the documentation there is an example in which PHP is used. The methods which is used are: openssl_get_privatekey, openssl_get_publickey, openssl_sign, openssl_verify.

So, I need to find methods from a module in Perl that does the same thing as the PHP-function does.

I searched around for modules and the one I found the best documentation for was Crypt::OpenSSL::RSA.

The documentation have an example which I tested a bit before I ended up here.

I need your help to get trough this part.

Can someone here explain how I can use Crypt::OpenSSL:RSA or another module that does the same task as the four functions I mentioned above?

I need to read in the private key first, which I'm calling private.pem in the same way that PHP does it: openssl_get_privatekey(file_get_contents(private.pem)). file_get_contents just reads in the hole file to a string and returns it. I don't need help with reading in a file to a string, that's a no-brainer. But where do I go from here ?

The second part is to use a similar function to PHP:s openssl_sign.

The third part is to use a similar function to PHP:s openssl_get_publickey

And last, the forth and final step, openssl_verify.

I don't have any code that I can bring to the table due that fact I don't have anything helpful at the moment.

Best regards,
Martin


In reply to Crypt::OpenSSL:RSA Questions by martin87

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.