2012-01-13 62 views
1

我從openssl-net.sourceforge.net庫,但有麻煩下載的包裝.NET爲在OpenSSL的拉泰什版本。錯誤嘗試使用OpenSSL .NET

我試圖加載這樣的private.key:

byte[] b = System.IO.File.ReadAllBytes(@"C:\SFDLL\private.key"); 
      OpenSSL.Core.BIO bio = new OpenSSL.Core.BIO(b); 
      OpenSSL.Crypto.CryptoKey key = OpenSSL.Crypto.CryptoKey.FromPrivateKey(bio, "123123"); 
      int i = 0; 

,並得到了錯誤: initializationOpenSSL.Core.Native exception

和內部異常是

{"Unable to load DLL 'libeay32': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"}

這不就是正確的方式做到這一點?我做錯了什麼?

回答

3

由於錯誤提示,無法找到libeay32。當你張貼OpenSSL.NET鏈路上的安裝說明狀態:

Installation

Make sure you have libeay32.dll and ssleay32.dll in the current working directory of your application or in your PATH. In your .NET project, add a reference to the ManagedOpenSsl.dll assembly.

所以一定要確保你有一個DLL的一個副本或者在你的build目錄,或地方,是你的系統路徑的一部分。

+0

你說得對,我把這些dll與導入到項目中的dll放在同一個地方,我認爲這已經足夠了,但是我用DLL更新了PATH,但是我沒有這個問題,但是不同的人,謝謝。 – ulisescastillo 2012-01-13 19:24:13

+0

可以作爲鏈接的項目將它們添加到您的項目,讓他們自動複製到構建\調試(或斌\發佈,或任何其他的路徑已配置)的庫。 – jeffora 2012-01-13 22:39:26