2014-12-04 61 views
-2

我试图在通过HTTPS连接将数据发送给服务器之前对其进行签名。我遇到的问题是,当我从id_rsa读取我的私钥时,它会给出错误。我的代码是使用Crypt :: RSA在perl中进行数据签名

use strict; 
use warnings; 
use Crypt::RSA; 

my $rsa = new Crypt::RSA (ES => 'PKCS1v15'); 
my $pkey = new Crypt::RSA::Key::Private (Filename => '/home/abc/.ssh/id_rsa'); 

print $pkey; 

上打印它给这样的错误Bareword found where operator expectedNumber found where operator expected

我无法理解可能是什么问题。

这样的错误消息开始Number found where operator expected at (eval 21) line 6, near "ZapzlA9gZ8 23" (Missing semicolon on previous line?) Bareword found where operator expected at (eval 21) line 6, near "23mqj2RsKOF0Lal7YbjYFkDE7YrLPktf0FNNYvn6BjKZDlyQfpWnk8dP3crjoown" (Missing operator before mqj2RsKOF0Lal7YbjYFkDE7YrLPktf0FNNYvn6BjKZDlyQfpWnk8dP3crjoown?) Number found where operator expected at (eval 21) line 9, near "QUgHQAJ4R 34" (Missing semicolon on previous line?) Bareword found where operator expected at (eval 21) line 9, near "34Csy0lcx" (Missing operator before Csy0lcx?) Having no space between pattern and following word is deprecated at (eval 21) line 10.

消息是

Can't use an undefined value as a HASH reference at Number found where operator expected at /usr/local/share/perl/5.14.2/Crypt/RSA/Key/Private.pm line 217.

有许多像上面这些之后,在最后一行行的
+0

通常存在与错误消息关联的行号和程序包名称。请显示所有必要的信息。 – 2014-12-04 05:45:55

+0

我提供了与错误关联的行号和程序包名称。谢谢 – shivams 2014-12-04 05:50:44

+0

SSH私钥文件不是Crypt :: RSA私钥文件,即使恰好使用RSA SSH密钥格式。 – hobbs 2014-12-04 06:13:00

回答

0

我建议尝试地穴: :如果可以的话,OpenSSL :: RSA。

+0

我试过使用Crypt :: OpenSSl :: RSA,但它给出错误'RSA.xs:178:OpenSSL错误:test.pl第20行不支持加密。我的第20行是'my $ privatekey = Crypt :: OpenSSL :: RSA-> new_private_key($ keystring);' – shivams 2014-12-07 10:44:27