EldoS | Feel safer!

Software components for data protection, secure storage and transfer

About ElX509Certificate.LoadKeyFromStreamPVK Methods

Also by EldoS: Callback File System
Create virtual file systems and disks, expose and manage remote data as if they were files on the local disk.
#5462
Posted: 03/17/2008 04:34:06
by  xu cong
protected TElX509Certificate TELX509 = new TElX509Certificate();
protected void Button1_Click(object sender, EventArgs e)
{
string pwd="1234";
FileStream FS = File.OpenRead("C:\\abcd.pvk");
TELX509.LoadKeyFromStreamPVK(FS, pwd, 0);
FS.Close();

FileStream FS2 = File.OpenRead("C:\\abcd.cer");
TELX509.LoadFromStream(FS2,0);
FS2.Close();

FileStream sFS = File.OpenWrite("C:\\test.pfx");
TELX509.SaveToStreamPFX(sFS, "1234");
sFS.Close();
}

The abcd.pvk password is "1234",When I not for the LoadKeyFromStreamPVK password, produces test.pfx does not have the private key; But after establishment password, run-time error.
Why don't I know?
#5463
Posted: 03/17/2008 04:40:43
by Ken Ivanov (EldoS Corp.)

Would you be so kind to specify the exact error message?
#5464
Posted: 03/17/2008 04:46:49
by  xu cong
NullReferenceException
#5474
Posted: 03/17/2008 21:51:58
by  xu cong
Execution Arrive:TELX509.LoadKeyFromStream­PVK(FS, pwd, 0);
Will appear NullReferenceException ;
#5477
Posted: 03/18/2008 02:17:29
by Ken Ivanov (EldoS Corp.)

You have to load a certificate prior to loading private key material. As you are trying to load the key into empty certificate object, there's no associated public key material and thus the exception is thrown.
#5478
Posted: 03/18/2008 02:38:11
by  xu cong
Thank you very much!
Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.

Reply

Statistics

Topic viewed 1798 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!