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

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


需要把当前的信息推送到政务网上,采用的是带证书的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完成。。。。。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值