我决定在我的自托管 wcf 应用程序中进行 net.tcp 绑定(使用传输级加密)。
虽然我在获取有关使自托管 wcf 应用程序工作的主题的信息方面度过了一段有趣的时光,但我当前的工作解决方案并未隐式指定绑定,因此我猜它默认为 BasicHttp。
我不确定如何“添加/更改”与 net.tcp 的绑定和传输级加密?我也对“测试”我的 tcp 安全连接感到好奇。什么将用于运行一些测试安全场景?
工作代码:未指定隐式绑定...
'create URI
Dim myServiceAddress As New Uri("http://" & LocalIpAddress & ":" & tcp_port & "/" & servicename)
Dim myservicehost As New ServiceHost(GetType(plutocomm), myServiceAddress)
' Enable metadata publishing.
Dim smb As New ServiceMetadataBehavior()
smb.HttpGetEnabled = True
smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15
myservicehost.Description.Behaviors.Add(smb)
myservicehost.Open()
更新
关于这个的更新......真的开始在这里挠我的头......
我现在有了:
将绑定更改为 tcp 创建、安装和引用的自签名证书跟踪显示没有有用的信息...
这是我的新代码:
Dim myServiceAddress As New Uri("net.tcp://" & localIpAddress & ":" & tcp_port & "/" & servicename)
Dim myservicehost As New ServiceHost(GetType(plutocomm))
'create binding
Dim myNetTcpBinding = New NetTcpBinding()
myNetTcpBinding.Security.Mode = SecurityMode.Transport
myNetTcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None
' Enable metadata publishing.
Dim smb As New ServiceMetadataBehavior()
smb.HttpGetEnabled = False
smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15
myservicehost.Description.Behaviors.Add(smb)
myservicehost.AddServiceEndpoint(GetType(Iplutocomm), myNetTcpBinding, myServiceAddress)
myservicehost.Credentials.ServiceCertificate.SetCertificate(StoreLocation.LocalMachine, StoreName.My, X509FindType.FindBySubjectName, "louisvantonder")
myservicehost.Open()
这是我在尝试引用它时带有“警告”的痕迹,没有关于为什么的真实信息......?
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>262171</EventID><Type>3</Type><SubType Name="Warning">0</SubType><Level>4</Level><TimeCreated SystemTime="2013-05-28T01:16:53.0868677Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{a696dcda-b24a-4838-9f23-cd0d67690af7}" /><Execution ProcessName="pluto" ProcessID="8472" ThreadID="3" /><Channel /><Computer>LOUISVANTONDER</Computer></System><ApplicationData><TraceData><DataItem><TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Warning"><TraceIdentifier>http://msdn.microsoft.com/en-ZA/library/System.ServiceModel.Channels.SocketConnectionAbort.aspx</TraceIdentifier><Description>SocketConnection aborted</Description><AppDomain>pluto.exe</AppDomain><Source>System.ServiceModel.Channels.SocketConnection/37489757</Source></TraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent>
我仍然无法获得可行的解决方案...这是我当前的代码