2015-07-07T16:09:50.137Z 2015-07-07T17:09:50.137Z
https://www.someserver.co.uk/cgi-bin/saml/saml.pl
CN=SeeMyData, OU=Web Security, O=SomeCompany, C=GB 126983547625965664326654654 encrypted string_1 goes here encrypted string_2 goes here _8fad4766-e906-4f78-b8aa-b1abdfe3f621 _8fad4766-e906-4f78-b8aa-b1abdfe3f621 urn:oasis:names:tc:SAML:2.0:assertion http://docs.oasis-open.org/ws-sx/ws-trust/200512/Issue http://docs.oasis-open.org/ws-sx/ws-trust/200512/Bearer
#### #!/usr/bin/perl ## Remove this when errors are resolved use diagnostics -verbose; #print warning diagnostics use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); use Convert::PEM; use Crypt::OpenSSL::RSA; use MIME::Base64; use strict; my $private_key = '/path/to/privatekey.pem'; my $encrypted_string =q(encrypted string_1 value); my $password = 'OurPassword'; my $key = decryptPrivate($private_key,$password,$encrypted_string); print "Content-type: text/html\n\n"; print "$key
"; exit; sub decryptPrivate { my ($private_key,$password,$string) = @_; my $key_string = readPrivateKey($private_key,$password); return(undef) unless ($key_string); # Decrypt failed. my $private = Crypt::OpenSSL::RSA->new_private_key($key_string) || die "$!"; $private->decrypt(decode_base64($string)); #$private->decrypt($string); } sub readPrivateKey { my ($file,$password) = @_; my $key_string; $key_string = decryptPEM($file,$password); } sub decryptPEM { my ($file,$password) = @_; my $pem = Convert::PEM->new( Name => 'RSA PRIVATE KEY', ASN => qq( RSAPrivateKey SEQUENCE { version INTEGER, n INTEGER, e INTEGER, d INTEGER, p INTEGER, q INTEGER, dp INTEGER, dq INTEGER, iqmp INTEGER } )); my $pkey = $pem->read(Filename => $file, Password => $password); return(undef) unless ($pkey); # Decrypt failed. $pem->encode(Content => $pkey); }