【发布时间】:2013-05-27 18:43:11
【问题描述】:
我决定在我的自托管 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>
我仍然无法找到可行的解决方案...这是我当前的代码
【问题讨论】:
-
网上肯定有一百万的教程,你有什么问题?
-
我肯定遗漏了一些基础知识......如前所述,上面的代码被“拼凑”在一起以掌握自托管实现。我不确定在哪里定义绑定类型和安全性?
-
那么在 TCP 传输加密中,您最好的尝试是什么?除了没有用谷歌搜索之外,您还有什么问题?
-
他可能已经用谷歌搜索过了,nvoigt。实际上很难在网上找到像样的答案,尤其是取决于一个人的搜索技巧,这就是为什么 SO 在这里。 (也就是说,路易斯,如果你还没有用谷歌搜索过,你可能还是想搜索一下。)
-
伙计们,我在过去的 48 小时里一直在这......就像我原来的帖子一样......我找到了关于需要发生什么的“理论/规范”,我还没有查找有关手动创建服务主机和指定绑定的自托管示例/信息...
标签: vb.net winforms wcf wcf-binding wcf-security