asp.net 调用带证书的webservice解决办法

简介: 最近在朋友弄一个调整省政府政务工作流的程序。。 需要把当前的信息推送到政务网上,采用的是带证书的https webservice。。 下面说一下实现过程 第一步,引用webservice地址,删除web.config中相关配置。同时安装好证书 用如下数据替换: <system.serviceModel> <bindings>

最近在朋友弄一个调整省政府政务工作流的程序。。


需要把当前的信息推送到政务网上,采用的是带证书的https webservice。。


下面说一下实现过程


第一步,引用webservice地址,删除web.config中相关配置。同时安装好证书


用如下数据替换:

  <system.serviceModel>
    <bindings>
      <customBinding>
        <binding name="IServiceSoapBinding" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00">
          <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
        messageVersion="Soap11" writeEncoding="utf-8">
            <!-- 政务大厅接口需要使用Soap11 -->
            <readerQuotas maxDepth="32" maxStringContentLength="819200000" maxArrayLength="1638400000"
              maxBytesPerRead="4096000" maxNameTableCharCount="16384000" />
          </textMessageEncoding>
          <httpsTransport manualAddressing="false" maxBufferPoolSize="52428800"
            maxReceivedMessageSize="6553600" allowCookies="false" authenticationScheme="Anonymous"
            bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
            keepAliveEnabled="true" maxBufferSize="6553600" proxyAuthenticationScheme="Anonymous"
            realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
            useDefaultWebProxy="true" requireClientCertificate="true" />
        </binding>
      </customBinding>
    </bindings>
    <client>
      <endpoint address="https://WebService网址/CXFWebService/webservice/iservice" behaviorConfiguration="endpointBehavior1" binding="customBinding" bindingConfiguration="IServiceSoapBinding" contract="ZwdtServices.IService" name="ServiceImplPort" />
    </client>
    <behaviors>
      <endpointBehaviors>
        <behavior name="endpointBehavior1">
          <dataContractSerializer maxItemsInObjectGraph="209715200"/>
          <clientCredentials>
            <clientCertificate  findValue="证书用户" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My"/>
            <serviceCertificate>
              <authentication certificateValidationMode="None"/>
              <!--<defaultCertificate findValue="ShanXi Digital Certificate Authority" x509FindType="FindBySubjectName" storeLocation="CurrentUser" storeName="My"/>-->
            </serviceCertificate>
          </clientCredentials>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>

但在实际调用时,提示找不到对应的证书用户


我猜测可能是iis用户访问证书有关,那么就在用户和计算机上都导入证书。运行MMC,打开两个证书管理器,都把证书导入一次。

如图




完成之后,果然错误不一样。。

继续运行,出现没有权限的错误



继续设计证书权限




OK完成。。。。。


目录
相关文章
|
.NET 开发工具
ASP.Net Core 运行错误 Http Error 502.5 解决办法
Http Error 502.5 - Process Failure 错误信息.png 如果你看到上面这张图片了的话,说明你在本地运行的时候报错了。
4430 0
|
.NET 网络架构 数据安全/隐私保护
|
.NET 开发框架 安全
IIS发布ASP.NET应用常见错误及解决办法
常见错误 配置文件错误 具体错误类型为HTTP 错误 500.19 - Internal Server Error,错误描述为由于权限不足而无法读取配置文件。
1330 0
|
JavaScript 前端开发 .NET
asp.net WebService实现跨域js调用功能实现
1、Web.Config中增加如下红色标记部分配置:                                                               2、增加一...
929 0