News  [SoftwareSite

Latest News
Older News
RSS Feed
 
Complete Projects
Useful Classes
Top Downloads
Message Board
AllAPI.net
 
Send Comments
Software License
Mentalis.org Buttons
Donate
 
Forums -> Security Library Forum
 
If a certificate is specified, it must have a private key  
by Vipps
posted on 2005/07/06

I have a pem file and i am creating a certificate from the pem file

SecurityOptions options = new SecurityOptions(sp);


Certificate cert = Certificate.CreateFromPemFile(clientCertPath);

options.Certificate = cert;
options.VerificationType = CredentialVerification.None
options.Entity = ConnectionEnd.Client;
options.CommonName = null;
options.Flags = SecurityFlags.Default;
options.AllowedAlgorithms = SslAlgorithms.ALL;

m_socClient = new SecureSocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp,options);

It throws an error "If a certificate is specified, it must have a private key"

by B. Ogatiy [bogatiy at hotmail dot com]
posted on 2005/08/29

I tried this using a .p12 file with CreateFromPfxFile and got the same error. Then using certmgr.exe, I exported the .p12 cert (that I installed for this export), and exported the certificate with private key to a .pfx file. Then I sed the same call and it worked fine.

Here are the pertinent lines of code:

SecurityOptions options = new SecurityOptions(SecureProtocol.Tls1 | SecureProtocol.Ssl3);

Certificate cert = Certificate.CreateFromPfxFile(@"c:\Cert.pfx","20yearsago");

options.Certificate = cert;

 

Copyright © 2002-2007, The Mentalis.org Team. All rights reserved.
This site is located at http://www.mentalis.org/
Send comments to the webmaster.