不在c#中创建SSl证书 [英] SSl certificate is not created in c#

查看:127
本文介绍了不在c#中创建SSl证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





这是我创建ssl证书的代码



ProcessStartInfo info = new ProcessStartInfo ();

处理p =新进程();

info.FileName = Server.MapPath(@〜\ Bin \ makekert.exe);

info.UseShellExecute = false;

info.Verb =runas; //提供以管理员身份运行

info.Arguments = @ - n+ @CN = ExampleSSL+ @ - b 12/10/2013 -e 01/05 / 2014 -r -sky exchange -pe -sr localMachine -ss my -sp+ @Microsoft RSA SChannel Cryptographic Provider+ @-sy 12 -sv example.pvk;

p.StartInfo = info;

p.Start();



这个没有例外的是同时没有创建证书。



请检查我的代号我错了



谢谢

purna

Hi,

this is my code to create ssl certificate

ProcessStartInfo info = new ProcessStartInfo();
Process p = new Process();
info.FileName = Server.MapPath(@"~\Bin\makecert.exe");
info.UseShellExecute = false;
info.Verb = "runas"; // Provides Run as Administrator
info.Arguments = @" -n " + @"""CN=ExampleSSL""" + @" -b 12/10/2013 -e 01/05/2014 -r -sky exchange -pe -sr localMachine -ss my -sp " + @"""Microsoft RSA SChannel Cryptographic Provider""" + @" -sy 12 -sv example.pvk";
p.StartInfo = info;
p.Start();

in this no exception is raising at the same time no certificate is created.

Please check my code where I did mistake

thanks
purna

推荐答案

试试在需要显示 SSL证书



public void SSLCErtificate()

{



HttpWebRequest request =(HttpWebRequest)WebRequest.Create(adrBarTextBox.Text);

HttpWebResponse response =(HttpWebResponse)request.GetResponse();

response.Close();



//检索ssl证书并将其分配给X509Certificate对象

X509Certificate cert = request.ServicePoint.Certificate;



//将X509Certificate转换为X509Certificate2对象,方法是将其转换为构造函数

X509Certificate2 cert2 = new X509Certificate2(cert);



//显示证书对话框

X509Certificate2UI .DisplayCertificate(cert2);

}



感谢你
Try to call this fucntion where you need to display SSL Certificate

public void SSLCErtificate()
{

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(adrBarTextBox.Text);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
response.Close();

//retrieve the ssl cert and assign it to an X509Certificate object
X509Certificate cert = request.ServicePoint.Certificate;

//convert the X509Certificate to an X509Certificate2 object by passing it into the constructor
X509Certificate2 cert2 = new X509Certificate2(cert);

//display the cert dialog box
X509Certificate2UI.DisplayCertificate(cert2);
}

Thanking you


这篇关于不在c#中创建SSl证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆