Is there any Cryptographic function which would simulate openssl_sign($data, $signature, $pkeyid); in ASP.NET?
I have a private key which is generated with OpenSSL application (http://www.slproweb.com/products/Win32OpenSSL.html) in .pem format and I need to sign piece of string with that private key, but
I can't get any info, so, please help..
First of all thanks a LOT. Obviously this is the way to go but I can't use the command to generate the pkcs12.
When I try to run that it just tells me the various options, do you have any suggestions? ;)
On what step do you run into the problem?
If it's on step 3, you just need to enter your company details (or you can even left those fields blank):
If it's on step 4, you just need to enter the password and repeat it after that (but keep in mind that you will not see it on the screen as you type it):
Aha! :9 I tried to run "openssl.exe pkcs12 -export ...." as it turns out you start openssl and then supply the commands. Thanks for clearing things up!
kipo
All-Star
16475 Points
2811 Posts
openssl_sign in ASP.NET
Sep 24, 2009 02:38 PM|LINK
Is there any Cryptographic function which would simulate openssl_sign($data, $signature, $pkeyid); in ASP.NET?
I have a private key which is generated with OpenSSL application (http://www.slproweb.com/products/Win32OpenSSL.html) in .pem format and I need to sign piece of string with that private key, but I can't get any info, so, please help..
kipo
All-Star
16475 Points
2811 Posts
Re: openssl_sign in ASP.NET
Sep 29, 2009 06:25 AM|LINK
I got a solution, so if anyone ever will be in a same situation, here is a procedure:
public string CreateSignature(string signatureString) { SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider(); X509Certificate2 cert = new X509Certificate2(MapPath("~/App_Data/P12File.p12"), "password"); RSACryptoServiceProvider rsaCryptoIPT = (RSACryptoServiceProvider)cert.PrivateKey; ASCIIEncoding encoder = new ASCIIEncoding(); byte[] binData = encoder.GetBytes(signatureString); byte[] binSignature = rsaCryptoIPT.SignData(binData, sha1); return Convert.ToBase64String(binSignature); }CatZ
Member
18 Points
14 Posts
Re: openssl_sign in ASP.NET
Aug 18, 2010 02:54 PM|LINK
Hi,
First of all thanks a LOT. Obviously this is the way to go but I can't use the command to generate the pkcs12.
When I try to run that it just tells me the various options, do you have any suggestions? ;)
kipo
All-Star
16475 Points
2811 Posts
Re: openssl_sign in ASP.NET
Aug 19, 2010 06:20 AM|LINK
On what step do you run into the problem?

If it's on step 3, you just need to enter your company details (or you can even left those fields blank):
If it's on step 4, you just need to enter the password and repeat it after that (but keep in mind that you will not see it on the screen as you type it):

CatZ
Member
18 Points
14 Posts
Re: openssl_sign in ASP.NET
Aug 19, 2010 06:45 AM|LINK
Aha! :9 I tried to run "openssl.exe pkcs12 -export ...." as it turns out you start openssl and then supply the commands. Thanks for clearing things up!
kobruleht
Member
589 Points
463 Posts
Re: openssl_sign in ASP.NET
May 21, 2011 03:23 PM|LINK
I tried this is MVC2 application
X509Certificate2 cert = new X509Certificate2(MapPath("~/App_Data/P12File.p12"), "" );
causes compile error
The name 'MapPath' does not exist in the current context
X509Certificate2 cert = new X509Certificate2(HttpContext.Current.Server.MapPath("~/App_Data/P12File.p12"), "" );
causes compile error
The name 'HttpContext' does not exist in the current context
How to use this method in MVC2 application controller ?
kusum
Member
6 Points
8 Posts
Re: openssl_sign in ASP.NET
May 06, 2013 12:43 PM|LINK
Hi Kipo ,
Can you please tell me what we we need to pass as "signatureString" parameter in the "CreateSignature" function?
Thanks,
Kusum
kipo
All-Star
16475 Points
2811 Posts
Re: openssl_sign in ASP.NET
May 07, 2013 09:54 AM|LINK