我正在运行一个 WCF 服务,除其他外,它被用作网站的后端。因为网站和 WCF 服务都运行在同一台机器上,为了性能,我设置了一个 netTcpBinding。
现在的问题是,因为它们存在于同一个盒子上,我真的不关心传输级安全性或消息级加密;截获消息的唯一可能方式是如果有人进入网络服务器本身,如果他们这样做,我已经遇到了更大的问题。
所以我的问题是:当客户端和服务器已经在一个受信任的子系统上时,可以使用什么配置来确保 netTcpBinding 尽可能快?
当然,答案可能是使用“无”的安全性。但在我的特殊情况下,我仍然需要对自定义数据库使用 UserName 身份验证。是否可以将其配置为仍然使用 UserName 身份验证,但不打扰证书或保护端点之间的数据?或者我是否可能需要使用自定义 SOAP 标头实现自定义行为来存储用户名/密码,然后我真的可以将安全设置为“无”?
服务器配置
<netTcpBinding>
<binding name="Net_Tcp_Binding">
<security mode="Message">
<message clientCredentialType="UserName" />
</security>
</binding>
</netTcpBinding>
它使用自定义用户名身份验证 - 基本上每个调用都针对自定义数据库进行身份验证和授权。服务端还使用证书与其客户端进行协商,例如:
<serviceBehaviors>
<behavior name="MyBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceAuthorization principalPermissionMode="Custom">
<authorizationPolicies>
<add policyType="MyAssembly.CustomAuthorizationPolicy,MyAssembly" />
</authorizationPolicies>
</serviceAuthorization>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="MyAssembly.CustomCredentialValidator,MyAssembly" />
<serviceCertificate x509FindType="FindBySubjectName" findValue="CN=servercert" storeLocation="LocalMachine" storeName="My" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
客户端配置
<netTcpBinding>
<binding name="Net_Tcp_Endpoint">
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="Message">
<message clientCredentialType="UserName" />
</security>
</binding>
</netTcpBinding>