有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

带有X509证书的c#WCF服务无法在Java客户端中使用

我已经在WCF中开发了一个带有x509认证安全性的服务,并部署在UAT上。我的net客户端可以使用该服务,也可以从该服务获得响应

然而,当我在Java中使用相同的服务时,我得到以下错误: 安全处理器无法在消息中找到安全标头。这可能是因为消息是不安全的错误,或者是因为通信双方之间存在绑定不匹配。如果服务配置为安全性,而客户端未使用安全性,则可能会发生这种情况

我的服务配置如下:

<?xml version="1.0"?>
<configuration>

   <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5"/>
  </system.web>

<system.diagnostics>
    <sources>
      <source name="System.ServiceModel.MessageLogging" switchValue="Warning,ActivityTracing">
        <listeners>
          <add type="System.Diagnostics.DefaultTraceListener" name="Default">
            <filter type="" />
          </add>
          <add name="ServiceModelMessageLoggingListener">
            <filter type="" />
          </add>
        </listeners>
      </source>
      <source propagateActivity="true" name="System.ServiceModel" switchValue="Warning,ActivityTracing">
        <listeners>
          <add type="System.Diagnostics.DefaultTraceListener" name="Default">
            <filter type="" />
          </add>
          <add name="ServiceModelTraceListener">
            <filter type="" />
          </add>
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add initializeData="C:\logs\web_messages.svclog"
        type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
        name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
        <filter type="" />
      </add>
      <add initializeData="C:\logs\web_tracelog.svclog"
        type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
        name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
        <filter type="" />
      </add>
    </sharedListeners>
  </system.diagnostics>


  <system.serviceModel>

 <diagnostics>
      <messageLogging logEntireMessage="true" logKnownPii="true" logMalformedMessages="true"
        logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
      <endToEndTracing propagateActivity="true" activityTracing="true"
        messageFlowTracing="true" />
    </diagnostics>

  <behaviors>
      <serviceBehaviors>
        <behavior>

          <serviceCredentials>
             <clientCertificate>
              <authentication certificateValidationMode="PeerOrChainTrust" revocationMode="NoCheck"  />
            </clientCertificate>
            <serviceCertificate findValue="myuatdomain.com"
                                storeLocation="LocalMachine" storeName="My"
                                x509FindType="FindBySubjectName" />
          </serviceCredentials>
      <serviceMetadata httpGetEnabled="true"  httpsGetEnabled="true"        
       httpsGetUrl="https://myuatdomain.com:7443/IR/Transaction.svc/mex"   />

          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <bindings>
      <basicHttpBinding>
    <binding name="CertBind" closeTimeout="00:20:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00"                
        maxBufferPoolSize="2147483647"  maxReceivedMessageSize="2147483647" >
            <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" 
            maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                <security mode="TransportWithMessageCredential">
                    <message clientCredentialType="Certificate" />
            <transport clientCredentialType="None" />
                </security>
        </binding>
      </basicHttpBinding>
    </bindings>

    <protocolMapping>
            <add binding="basicHttpsBinding"  scheme="https" />
    </protocolMapping>

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false" />
    <services>
            <service name="InwardRemittanceService.Transaction">
                <endpoint name="basic" address="https://myuatdomain.com:7443/IR/Transaction.svc/mex"  
        binding="basicHttpBinding" contract="IRService.ITransaction" bindingConfiguration="CertBind" >
         <identity>
            <dns value="myuatdomain.com"/>
            <certificateReference findValue="myuatdomain.com" storeLocation="LocalMachine" storeName="My" 
            x509FindType="FindBySubjectName" />
        </identity>
        </endpoint>
            </service>
     </services>  
  </system.serviceModel>

</configuration>

非常感谢您的帮助


共 (0) 个答案