XML digital signatures in Perl

GreasyTony

New Member
I'm trying to digitally sign XML in Perl using the \[code\]Crypt::OpenSSL::RSA\[/code\] module. I'm loading a private key from a file. The private key was generated from a keystore using Java.Below is my Perl code:\[code\]my $private = 'my_priv.key';my $private_key = read_file( $private );print "my private key text is\n", $private_key;\[/code\]Output, not putting the entire key here, just the few first lines :-)\[code\]> -----BEGIN PRIVATE KEY----- MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKAuqJ1ZkxHZStfSt0CdEsaSYuLO> 6zDiTpt60asVLWpLe2bf...\[/code\]
\[code\]my $rsa_priv = Crypt::OpenSSL::RSA->new_private_key($private_key);print "my private key is\n",$rsa_priv->get_private_key_string();\[/code\]Output:\[code\]> -----BEGIN RSA PRIVATE KEY-----> MIICXAIBAAKBgQCgLqidWZMR2UrX0rdAnRLGkmLizusw4k6betGrFS1qS3tm3+97> wMvFXCx0Od8eb\[/code\]The results of \[code\]$private_key\[/code\] and \[code\]$rsa_priv->get_private_key_string()\[/code\] are different. Is it supposed to behave like that?Has anyone been able to sign XML using \[code\]Crypt::OpenSSL::RSA\[/code\]?edit:i'm using java code to extract the private key, code is as below `KeyStore ks = KeyStore.getInstance("JKS");\[code\]keypass = sPass.toCharArray();FileInputStream fis = new FileInputStream(store);ks.load(fis, sPass.toCharArray());fis.close();String eol = System.getProperty("line.separator");Key k = ks.getKey(alias, keypass);System.out.println("....Generating the Private Key.....");String encKey = new BASE64Encoder().encode(k.getEncoded());System.out.println("Encoded Key: " + encKey);BufferedWriter myKey = null;myKey = new BufferedWriter(new FileWriter(alias + "_priv.key"));myKey.write("-----BEGIN PRIVATE KEY-----" + eol);myKey.write(encKey + eol);myKey.write("-----END PRIVATE KEY-----");myKey.close();System.out.println("....Private Key Generated.....");`\[/code\]using both java and perl because the xmls i'm trying to sign are in perl (it's a whole big system) and the keystore is in java.First time digitally signing anything and my digitally signed xml is not authenticating at all to the recipient system
 
Back
Top