SSL证书生成
我正在开发 C# 项目,其中服务器和客户端之间的 tcp 传输是使用 SSL 进行的。我使用 makecert 程序创建了证书文件,但它仅适用于生成它的计算机(尽管我已经安装了 .cer 文件)。我几乎可以肯定,问题出在我输入命令的参数中,但我检查了许多组合,没有一个(尽管有以下)有效的
makecert -r -pe -n "CN=This is my certificate" -ss my -sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12 ca.cer
.cer 文件仅用于加密传输。我不使用 PKI。此外,使用 SSL 是“死要求”——它必须被使用,只是为了被使用。不应考虑任何安全问题。
如果有人回答我如何创建证书,该证书将能够通过 X509Certificate.CreateFromCertFile 方法使用,我会很高兴。
I am working on C# project where tcp transmition between server and client is made using SSL. I created certificate file with makecert program, but it works only on computer where it was generated (although I have installed .cer file). I am almost sure, that the problem lies in parameters which I put into command, but I checked many combinations and none (despit following) worked
makecert -r -pe -n "CN=This is my certificate" -ss my -sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12 ca.cer
.cer file is used only for ciphering transmition. I don't use PKI. Furthermore using SSL is "dead requirement" - it must be used, just for be used. Any security issues shouldn't be considered.
If anyone should answer me, how to create certificate, that will be able to be used by X509Certificate.CreateFromCertFile method I would be delighted.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
谢谢罗杰,我找到了你的博客,并设法让它工作并对其进行包装,以便它易于使用,我还设法在证书上设置友好名称
示例使用
SSLCertificateCreator.MakeCACertificate(“DavesRoot”,“Nice Name” );
SSLCertificateCreator.MakeSignedCertificate("DavesRoot", "Daves 签名证书5","好名字");
makecert.exe 需要位于 Bin/Release 或 Debug 目录中,代码才能工作,并且此代码仅在 Windows-8 上进行过测试
Thanks Roger I found your blog and managed to get it working and put a wrapper around it so it's easy to use and I also managed to set the friendly-Name on the certificates
Sample useage
SSLCertificateCreator.MakeCACertificate("DavesRoot","Nice Name");
SSLCertificateCreator.MakeSignedCertificate("DavesRoot", "Daves Signed Certificate5","Nice Name");
makecert.exe needs to be in the Bin/Release or Debug directory for the code to work and this code has only ever been tested on Windows-8
如果您控制将使用这些证书的所有计算机,则可以创建一个受所有计算机信任的 CA,然后基于该证书颁发证书。
这是我的批处理文件。第一个创建 CA 证书:
将 .CER 文件导入到必须连接到服务器的那些计算机上的 CA 证书存储中(它们必须信任 CA):
这个创建服务器证书:
安装 .pfx 文件,然后获取 C# 服务器代码以使用它。这留给读者作为练习。
If you control all of the machines that will use these certificates, you can create a CA that's trusted by all of the machines, and then issue certificates based on that.
Here are my batch files. The first one creates the CA certificate:
Import the .CER file into the CA certificate store on those machines that must connect to the server (they must trust the CA):
This one creates a server certificate:
Install the .pfx file, and then get the C# server code to use it. This is left as an exercise for the reader.
您需要获得有效的证书。 makecert 命令生成的仅用于测试,无法在其他系统上运行。
You need to get a valid certificate. The one generated by makecert command is only for testing and wont work on other systems.