2014-12-04 66 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