小编Kri*_*ost的帖子

我可以在.NET配置部分中添加textnode而不是属性吗?

我目前有一个.NET自定义配置部分,如下所示:

<customSection name="My section" />
Run Code Online (Sandbox Code Playgroud)

我想要的是将它写为textnode(我不确定这是否是正确的术语?),如下所示:

<customSection>
  <name>My Section</name>
</customSection>
Run Code Online (Sandbox Code Playgroud)

我当前的customSection类看起来像这样:

public class CustomSection: ConfigurationSection {

  [ConfigurationProperty("name")]
  public String Name {
    get {
      return (String)this["name"];
    }
  }

}
Run Code Online (Sandbox Code Playgroud)

我该怎么做才能使它成为一个textnode?

c# asp.net configuration web-config

17
推荐指数
2
解决办法
3516
查看次数

如何在WCF服务中将密码与我的证书(X.509)一起发送?

我有一个WCF服务,它使用X.509证书作为客户端凭据.大多数这些凭据不需要密码来使用它,只是为了安装它.

但是现在,我们的客户有一个证书,每次使用时都要输入密码(即每次服务运行时).此服务每天调用另一个服务n次,但如果无法验证证书则会失败.

到目前为止,我们已经要求我们的客户在每次遇到这个问题时订购(并支付)新证书,但我和我们的客户都厌倦了每次都要经历这个问题.我还没有使用自己的服务,并没有太多与WCF服务的经验.

我想知道的是:是否可以在配置文件中输入此密码以及有关证书的所有其他信息?

以下是该服务的XML配置的一部分:

<configuration>
  <system.serviceModel>
    <client>
      <endpoint
        address="***"
        binding="basicHttpBinding"
        bindingConfiguration="***"
        behaviorConfiguration="HTTPSEndpoint"
        contract="***"
        name="***" />
    </client>
    <bindings>
      <basicHttpBinding>
        <binding
          name="***"
          sendTimeout="00:05:00"
          maxBufferSize="2147483647"
          maxReceivedMessageSize="2147483647" >
          <readerQuotas maxStringContentLength="2147483647" />
          <security mode="Transport">
            <transport clientCredentialType="Certificate" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <endpointBehaviors>
        <behavior name ="HTTPSEndpoint">
          <clientCredentials>
            <clientCertificate
              findValue="***"
              storeLocation="LocalMachine"
              storeName="My"
              x509FindType="FindBySubjectName"/>
          </clientCredentials>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>
Run Code Online (Sandbox Code Playgroud)

.net wcf x509certificate

5
推荐指数
1
解决办法
1304
查看次数

标签 统计

.net ×1

asp.net ×1

c# ×1

configuration ×1

wcf ×1

web-config ×1

x509certificate ×1