使用带有自签名证书的传输安全性的 BasicHttpBinding

2024-07-03

我有 WCF 服务,在一个 ServiceHost 内的不同端点使用 BasicHttpBinding 和 NetTcpBinding。 NetTcp 使用自签名证书,该证书是从文件加载的,一切都很好,直到我尝试实际使用 BasicHttpBinding,所以我这样做:

在服务器上:

var ServiceHost host = new ServiceHost(blah blah);
host.Credentials.ServiceCertificate.Certificate = GetCertificate(); //load a certificate from file
host.Credentials.ClientCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
var httpBinding = new BasicHttpBinding();
httpBinding.Security.Mode = BasicHttpSecurityMode.Transport;
httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;

在客户端:

ChannelFactory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
var cer = GetCertificate();
ChannelFactory.Credentials.ClientCertificate.Certificate = cer;

var httpBinding = new BasicHttpBinding();
httpBinding.Security.Mode = BasicHttpSecurityMode.Transport;
httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
//accept any cert
System.Net.ServicePointManager.ServerCertificateValidationCallback =
                ((sender, certificate, chain, sslPolicyErrors) => true);

但是当连接时,我收到此错误

异常 - 发生错误 发出 HTTP 请求https://localhost/MyService https://localhost/MyService。这 可能是因为 服务器证书未配置 正确使用 HTTPS 中的 HTTP.SYS 案件。这也可能是由 安全绑定不匹配 客户端和服务器之间。

证书未安装,并且它与 net tcp 绑定一起工作正常,我想我一定错过了一些小东西?

我注意到的一件事是 net.tcp 是双工通道,而基本 http 是单工通道,我确信设置有区别?例如,我需要在两端加载net.tcp的证书,那么基本的http会发生什么情况呢?

提前致谢


WCF 配置中未配置 HTTPS 证书。您必须为 http.sys 配置证书。要做到这一点,请使用执行程序 http://msdn.microsoft.com/en-us/library/ms733791.aspx从具有提升权限的命令行。如果您在 IIS/WAS 中托管服务,则不必使用 netsh,您可以直接在 IIS 中配置 HTTPS http://learn.iis.net/page.aspx/144/how-to-set-up-ssl-on-iis-7/.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用带有自签名证书的传输安全性的 BasicHttpBinding 的相关文章

随机推荐

  • 如何在窗口上覆盖控件?

    现在我有一个带有一堆控件的普通窗口 当用户点击某个按钮时 我想调暗整个窗口 然后在其顶部显示一个弹出窗口 不是真正的对话框 只是窗口内的东西 所以这就是我的理论 每个控件都位于第 0 层 有一个与第 1 层中的形状大小相同的矩形 它的透明度
  • 是否可以关闭 TomCat 中的热部署?

    tomcat中是否可以关闭热部署 以前有人这样做过吗 请建议 是的 在 server xml 中的 Host 元素上设置 autoDeploy false
  • 是否可以关闭 TomCat 中的热部署?

    tomcat中是否可以关闭热部署 以前有人这样做过吗 请建议 是的 在 server xml 中的 Host 元素上设置 autoDeploy false
  • 为什么Jsoup无法选择td元素?

    我做了一些测试 使用 Jsoup 1 6 1 String s Jsoup parse td td select td size System out println Selected elements count s 它输出 Select
  • 为什么Jsoup无法选择td元素?

    我做了一些测试 使用 Jsoup 1 6 1 String s Jsoup parse td td select td size System out println Selected elements count s 它输出 Select
  • 使用游标适配器实现具有多个选择和过滤器的列表视图

    这个问题在这个问题中讨论Android 过滤列表视图时检查了错误的项目 https stackoverflow com questions 7874668 android wrong item checked when filtering
  • 使用游标适配器实现具有多个选择和过滤器的列表视图

    这个问题在这个问题中讨论Android 过滤列表视图时检查了错误的项目 https stackoverflow com questions 7874668 android wrong item checked when filtering
  • 获取当前周数 (C#)

    我一直在查看微软的文档和许多堆栈溢出帖子 但似乎没有一个回答我的问题 我想知道在 C 中获取当前日期的准确周数的最简单和最简单的方法 我对 C 还很陌生 所以请尽量保持简单 我尝试过使用 int week DateTime Now DayO
  • 获取当前周数 (C#)

    我一直在查看微软的文档和许多堆栈溢出帖子 但似乎没有一个回答我的问题 我想知道在 C 中获取当前日期的准确周数的最简单和最简单的方法 我对 C 还很陌生 所以请尽量保持简单 我尝试过使用 int week DateTime Now DayO
  • 缩小 Webview 内容宽度以适合屏幕

    我试图缩小我的网络视图的宽度内容以适应我的屏幕 这样我就不必再横向滚动了 我尝试了很多代码 但仍然没有人知道怎么办 到目前为止 这是我的代码 postView WebView findViewById R id postView postV
  • 缩小 Webview 内容宽度以适合屏幕

    我试图缩小我的网络视图的宽度内容以适应我的屏幕 这样我就不必再横向滚动了 我尝试了很多代码 但仍然没有人知道怎么办 到目前为止 这是我的代码 postView WebView findViewById R id postView postV
  • 我们是否也应该在 Golang 中关闭 DB 的 .Prepare() ?

    From this https github com mindreframer golang stuff tree master github com VividCortex go database sql tutorial教程表明rows
  • 我们是否也应该在 Golang 中关闭 DB 的 .Prepare() ?

    From this https github com mindreframer golang stuff tree master github com VividCortex go database sql tutorial教程表明rows
  • Phpstorm 超慢 - CPU 使用率 282.8%

    在使用 Netbeans 工作了 5 年多之后 我想尝试一下朋友推荐的 Phpstorm 我下载了 Phpstorm 的新副本 并在 IDE 中导入了一个新项目 结果太糟糕了 Phpstorm 在启动过程中非常慢 进行 SVN 提交需要 5
  • Phpstorm 超慢 - CPU 使用率 282.8%

    在使用 Netbeans 工作了 5 年多之后 我想尝试一下朋友推荐的 Phpstorm 我下载了 Phpstorm 的新副本 并在 IDE 中导入了一个新项目 结果太糟糕了 Phpstorm 在启动过程中非常慢 进行 SVN 提交需要 5
  • BeautifulSoup - 提取属性值

    如果 Beautiful Soup 给了我一个像这样的锚标签 a class blah blah href link html a 我将如何检索的值href属性 如果您已经有了锚点 请抓住href像这样的属性 href anchor hre
  • BeautifulSoup - 提取属性值

    如果 Beautiful Soup 给了我一个像这样的锚标签 a class blah blah href link html a 我将如何检索的值href属性 如果您已经有了锚点 请抓住href像这样的属性 href anchor hre
  • 使用 Lambda 设置 DynamoDB 触发器

    我正在尝试使用 DynamoDB Streams 和 AWS Lambda 创建 DynamoDB 触发器 我进行了很多研究 但找不到任何方法来读取和处理 Java 8 中的 DynamoDB Stream 事件 我对这两种技术都是全新的
  • 使用 Lambda 设置 DynamoDB 触发器

    我正在尝试使用 DynamoDB Streams 和 AWS Lambda 创建 DynamoDB 触发器 我进行了很多研究 但找不到任何方法来读取和处理 Java 8 中的 DynamoDB Stream 事件 我对这两种技术都是全新的
  • 使用带有自签名证书的传输安全性的 BasicHttpBinding

    我有 WCF 服务 在一个 ServiceHost 内的不同端点使用 BasicHttpBinding 和 NetTcpBinding NetTcp 使用自签名证书 该证书是从文件加载的 一切都很好 直到我尝试实际使用 BasicHttpB