是否可以强制 WCF 测试客户端接受自签名证书?
我有一个使用自签名证书在 IIS 7 中运行的 WCF Web 服务(这是一个概念证明,以确保这是我想要走的路线)。需要使用 SSL。
是否可以使用 WCF 测试客户端来调试此服务,而无需非自签名证书?
当我尝试时出现此错误:
错误:无法从中获取元数据 https:///Service1.svc 如果这是 Windows (R) 通信 您拥有的基金会服务 访问权限,请检查您是否拥有 启用元数据发布 指定地址。如需帮助启用 元数据发布,请参考 MSDN 文档位于 http://go.microsoft.com/fwlink/?LinkId=65455.WS -元数据 交换错误 URI: https:///Service1.svc 元数据包含一个参考 无法解决: 'https:///Service1.svc'。 无法建立信任关系 对于 SSL/TLS 安全通道 权威 ''。这 底层连接已关闭: 无法建立信任关系 用于 SSL/TLS 安全通道。这 远程证书无效 根据验证 procedure.HTTP GET 错误 URI: https:///Service1.svc 下载时出现错误 'https:///Service1.svc'。 底层连接已关闭: 无法建立信任关系 用于 SSL/TLS 安全通道。这 远程证书无效 根据验证程序。
编辑:这个问题具体是关于使用 WCF 测试客户端 来测试已使用自签名证书通过 SSL 保护的 Web 服务。服务器已设置为接受提供的任何证书,这是 WCF 测试客户端,我看不到执行此操作的方法。
I have a WCF web service running in IIS 7 using a self-signed certificate (it's a proof of concept to make sure this is the route I want to go). It's required to use SSL.
Is it possible to use the WCF Test Client to debug this service without needing a non-self-signed certificate?
When I try I get this error:
Error: Cannot obtain Metadata from
https:///Service1.svc
If this is a Windows (R) Communication
Foundation service to which you have
access, please check that you have
enabled metadata publishing at the
specified address. For help enabling
metadata publishing, please refer to
the MSDN documentation at
http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata
Exchange Error URI:
https:///Service1.svc
Metadata contains a reference that
cannot be resolved:
'https:///Service1.svc'.
Could not establish trust relationship
for the SSL/TLS secure channel with
authority ''. The
underlying connection was closed:
Could not establish trust relationship
for the SSL/TLS secure channel. The
remote certificate is invalid
according to the validation
procedure.HTTP GET Error URI:
https:///Service1.svc
There was an error downloading
'https:///Service1.svc'.
The underlying connection was closed:
Could not establish trust relationship
for the SSL/TLS secure channel. The
remote certificate is invalid
according to the validation procedure.
EDIT: This question is specifically about using the WCF Test Client to test a web service already secured via SSL using a self-signed certificate. The server is already set up to accept any certificate provided, it's the WCF Test Client I don't see a way to do this for.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
您可以在开发区域创建一个非自签名证书,然后在 IIS 中使用该证书来应用 SSL。步骤是:
创建自签名证书
为 SSL 创建一个由该根证书签名的非自签名证书,然后从中创建 pfx 文件
现在您只需导入
server.pfx
进入 IIS 并设置网站绑定以使用此证书,并在本地计算机
\中安装
存储在服务器和客户端中,通过执行此操作,WCF 客户端将通过 HTTPS 使用服务,不会出现任何问题。CA.cer
>受信任的根证书颁发机构You can create a non self-signed certificate in development area and then use this certificate in IIS for applying the SSL. The steps are:
Create self-signed certificate
Create a non self-signed certificate for SSL which signed by this root certificate and then create pfx-file from that
now you just need to import the
server.pfx
into the IIS and setup the web site binding to use this certificate and also install theCA.cer
inLocal Computer
\Trusted Root Certification Authorities
store in both server and client by doing this WCF client would work with the service through HTTPS without any problem.如果您将 WCF 测试客户端替换为 WCFStorm Lite Edition。它是免费的,并且比 MS 的测试客户端更加灵活......例如,它可以让您指定用户名和密码。密码(如果您正在进行用户名身份验证)。
you should be able to do this if you replace the WCF Test Client with WCFStorm Lite Edition. It's free and is quite a bit more flexible than MS's test client... for example, it'll let you specify a user name & password if you're doing username authentication.
这个问题的答案有帮助就我而言。请务必使用证书所期望的准确机器名称。例如,
machine/service.svc
可能无法工作,而machine.domain/service.svc
- 可以工作。The answer from this question helped in my case. Be sure to use exact machine name as certificate expects. For exampe
machine/service.svc
may not work, whilemachine.domain/service.svc
- works.要回答您的问题...以下是如何强制 WCF 测试客户端接受自签名证书...
To answer your question... here is how you force your WCF test client to accept a self-signed certificate...
是的,这是可能的。
只需从服务下载生成的 WSDL (https://localhost/Service1.svc?singleWsdl) 并在 WCF 测试客户端中添加服务时提供此文件的路径。
Yes it is possible.
Just download the generated WSDL from the service (https://localhost/Service1.svc?singleWsdl) and supply the path to this file when adding a service in the WCF Test Client.
在 IIS 中将
https
绑定添加到我的网站并选择 IIS Express 开发证书后,我遇到了同样的问题。事实证明,要使
https
正常工作,我还必须输入绑定的主机名。就我而言,localhost
。I had the same issue after adding a
https
binding to my site in IIS and choosing the IIS Express Development Certificate.It turned out that for
https
to work I also had to input the host name for the binding. In my caselocalhost
.您可以提供自己的方法来验证证书。
试试这个:
回电:
You can supply your own method to validate the certificate.
Try this:
The call back: