简体   繁体   English

Windows服务器中的自签名证书

[英]self signed certificate in windows server

I have a C# console app that consumes a web service that is outside of my network. 我有一个C#控制台应用程序,它使用我网络之外的Web服务。 I am told that the web services uses self-signed certificate for SSL. 我被告知Web服务使用SSL的自签名证书。 I am not familiar with the certificate and I am wondering what I need to do in .net/windows server environment. 我不熟悉证书,我想知道在.net / windows服务器环境中我需要做什么。

Thanks. 谢谢。

Self signed certificates will not be viewed by your application as valid by default because there is not a trusted third party validating the certificate. 默认情况下,您的应用程序不会将自签名证书视为有效,因为没有可信任的第三方验证证书。 Typically you'll see self signed certificates on test servers, and you can find more info on self signed versus signed certificates here . 通常,您会在测试服务器上看到自签名证书,您可以在此处找到有关自签名证书和签名证书的更多信息。

If you are having trouble calling the web services then you'll need to either install the certificate on the machine that your application is running on, or create a custom validator that you can use to tell your application to accept the self signed certificate. 如果您在调用Web服务时遇到问题,则需要在运行应用程序的计算机上安装证书,或者创建可用于告知应用程序接受自签名证书的自定义验证程序。 From .NET 2.0 onward, custom SSL validation is done by specifying a custom method on the ServicePointManager.ServerCertificateValidationCallback property. 从.NET 2.0开始,通过在ServicePointManager.ServerCertificateValidationCallback属性上指定自定义方法来完成自定义SSL验证。

An example of using the ServerCertificateValidationCallback property can be found here: http://weblogs.asp.net/smehaffie/archive/2009/09/10/calling-web-services-that-use-self-signed-certificates.aspx 可以在此处找到使用ServerCertificateValidationCallback属性的示例: http ://weblogs.asp.net/smehaffie/archive/2009/09/10/calling-web-services-that-use-self-signed-certificates.aspx

That's a large question especially regarding X.509 security. 这是一个很大的问题,特别是关于X.509安全性。 Usually with self-signed certificate, you have to import the initial CA used to sign this certificate (usually the self-signed CA used by the application) into your keyring (to be sure that you are connecting to the right server). 通常使用自签名证书,您必须导入用于将此证书(通常是应用程序使用的自签名CA)签名的初始CA导入密钥环(以确保您连接到正确的服务器)。 It's usually required because your client application will check at the connection if the certificate is signed by a known and trusted CA or matching an existing certificate in your keyring. 这通常是必需的,因为如果证书由已知且受信任的CA签名或与密钥环中的现有证书匹配,则客户端应用程序将检查连接。

In C#, you can check the System.Net.Security namespace and especially the SSlStream class for more details. 在C#中,您可以检查System.Net.Security命名空间 ,尤其是SSlStream类以获取更多详细信息。

If you need to import certificate in your keyring, you can use various interfaces to access the keyring from the GUI , using the command line "Certutil.exe" or via the various APIs . 如果需要在密钥环中导入证书,可以使用各种界面从GUI访问密钥 ,使用命令行“Certutil.exe”或通过各种API

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM