How to do Authentication using Public key ? - WeOnlyDo Discussion board

How to do Authentication using Public key ? (General questions)

by Sugi, Thursday, November 08, 2012, 09:39 (4194 days ago)

Hi,

I am having a public key in a text file.

Please guide me with a Sample VB code
a. how to do authentication for Public Key
b. how to load my public key from a file

Also, please let me know, whether i can use any one of these authentications for public key
(AuthAutomatic/AuthBasic/AuthDigest/Authnone/AuthNTLM)

Thanks in advance for your great help.
SUGI

Re: How to do Authentication using Public key ?

by wodDamir, Thursday, November 08, 2012, 10:01 (4194 days ago) @ Sugi

Sugi,

Did you try the code in the following URL:

http://www.weonlydo.com/HttpDLX/Help/wodHttpDLX-Certificate.html

If not, can you please try it out?

Regards,
Damba

Re: How to do Authentication using Public key ?

by Sugi, Thursday, November 08, 2012, 10:42 (4194 days ago) @ wodDamir

Hi Damba,

I tried the http://www.weonlydo.com/HttpDLX/Help/wodHttpDLX-Certificate.html

as below
To Generate the Private key
Dim wodHttp1 As New wodHttpDLXCom
Set wodHttp1.Certificate = New Certificate
wodHttp1.Certificate.GenerateKey 0 'RSAkey
wodHttp1.Certificate.SaveKey C:mykey.txt

And Used that private key with my certificate

m_wodCertificate.LoadKey c:mykey.txt
m_wodCertificate.Load D:SS22232_Amexfsgatewaytest_certificatefsgatewaytest_certificate.crt

But i am getting an error Private key does not belong to the certificate.

Please Help!

Thanks
SUGI

Re: How to do Authentication using Public key ?

by wodDamir, Thursday, November 08, 2012, 13:28 (4194 days ago) @ Sugi

Sugi,

You cannot use any key with any certificate. Private key has to be generated along with the certificate.

What format do you have certificate in? .pfx certificate usually contains PrivateKey in it so you can use the same file for both, LoadKey and Load methods.

Regards,
Damba

Re: How to do Authentication using Public key ?

by Sugi, Thursday, November 08, 2012, 13:36 (4194 days ago) @ wodDamir

Hi Damba,

The certificate format that I have is .crt

I have the certificate file only and don't have private key associated with that certificate.
Please let me know the way to generate the private key for the certificate that I have ?

Thanks
SUGI

Re: How to do Authentication using Public key ?

by wodDamir, Thursday, November 08, 2012, 14:33 (4194 days ago) @ Sugi

Sugi,

You can't. Certificate is derived from PrivateKey. However, are you even sure that you actually need Private key?

Perhaps it's enough to provide certificate only?

Regards,
Damba

Re: How to do Authentication using Public key ?

by Sugi, Thursday, November 08, 2012, 14:56 (4194 days ago) @ wodDamir

Hi Damba,

I have the certificate, but I don't have the private key associated for that certificate.

However, when I tried the loading the certificate ( .crt format) with out private key, it throws an error Failed to load key or certificate. Password invalid?

Can you help me to overcome this, with a sample VB code

Thanks
SUGI

Re: How to do Authentication using Public key ?

by wodDamir, Thursday, November 08, 2012, 15:59 (4194 days ago) @ Sugi

Sugi,

do you know the password for the certificate? If so, you need to provide it along with Load method as a second parameter. i.e:

http1.Certificate.Load your_cert_path , your_cert_password

Can you try that?

Regards,
Damba