Bei Message Security mit UserName tritt immer folgender Fehler auf was habe ich falsch gemacht?
-
lunes, 23 de mayo de 2011 9:03
Hallo,
ich versuche momentan bei einem WCF Service die Message-Sicherheit zu implementieren. Ich verwende Visual Studio 2008 mit dem .Net Framework 3.5.
Jedoch erhalte ich immer folgenden Fehler:
Ein nicht gesicherter oder fehlerhaft gesicherter Fehler wurde vom andern Teilnehmer empfangen. Den Fehlercode und Details finden sie unter der inneren FaultException.
Inneren FaultException: Fehler beim überprüfen der Sicherheit für die Nachricht.
Beim Tracen ist das die erste Warnung die ich erhalte danach wird der oben angegeben Fehler ausgegeben.
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"> <System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"> <EventID>458784</EventID> <Type>3</Type> <SubType Name="Warning">0</SubType> <Level>4</Level> <TimeCreated SystemTime="2011-05-23T06:43:06.9062500Z" /> <Source Name="System.ServiceModel" /> <Correlation ActivityID="{785e8f57-7268-4cc7-b668-72d4e7f88ab9}" /> <Execution ProcessName="Service" ProcessID="484" ThreadID="3" /> <Channel /> <Computer>localhost</Computer> </System> <ApplicationData> <TraceData> <DataItem> <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Warning"> <TraceIdentifier>http://msdn.microsoft.com/de-DE/library/System.ServiceModel.Security.SecurityBindingVerifyIncomingMessageFailure.aspx</TraceIdentifier> <Description>The security protocol cannot verify the incoming message.</Description> <AppDomain>Service.exe</AppDomain> <ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/SecurityProtocolTraceRecord"> <SecurityProtocol>System.ServiceModel.Security.SymmetricSecurityProtocol</SecurityProtocol> <Action>http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT</Action> <To>net.tcp://localhost:[port]/UspService/OpcUaClient</To> <EndpointReference xmlns="http://www.w3.org/2005/08/addressing"> <Address>http://www.w3.org/2005/08/addressing/anonymous</Address> </EndpointReference> <MessageId>urn:uuid:34e3ae47-1fa5-448d-92b4-b9bcaf788c94</MessageId> </ExtendedData> </TraceRecord> </DataItem> </TraceData> </ApplicationData> </E2ETraceEvent>
Das Verwendete Zertifikat befindet sich im Ordner My und TrustedPeople.
Zum jetzigen Zeitpunkt laufen Server und Client auf demselben Rechner.
Die Sicherheitseinstellungen des Services ist auf „This is a full trust application“ gesetzt.
Meine Konfiguration auf Seiten des Servers:
<bindings> <netTcpBinding> <binding name="NetTcpBinding" receiveTimeout="00:02:00" portSharingEnabled="false"> <reliableSession inactivityTimeout="09:00:00" enabled="false"/> <security mode="Message"> <message clientCredentialType="UserName"/> </security> </binding> </netTcpBinding> </bindings>
…
<behaviors> <serviceBehaviors> <behavior name="UspMachineCoupling.cConnectionBehavior"> <serviceMetadata httpGetEnabled="false" /> <serviceDebug includeExceptionDetailInFaults="true" /> <serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="UspSqlRoleManager"/> <serviceCredentials> <userNameAuthentication userNamePasswordValidationMode="MembershipProvider"
membershipProviderName="UspSecuritySqlMembershipProvider"/> <serviceCertificate findValue="UA Test Client" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName"/> </serviceCredentials> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> <system.web> <membership defaultProvider="UspSecuritySqlMembershipProvider"> <providers> <add name="UspSecuritySqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider"
connectionStringName="UspSecurityConnectionString"
enablePasswordRetrieval="false" enablePasswordReset="true"
requiresQuestionAndAnswer="true" applicationName="SecurityTutorials"
requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1"
passwordAttemptWindow="10" passwordStrengthRegularExpression="" /> </providers> </membership> <roleManager enabled="true" defaultProvider="UspSqlRoleManager"> <providers> <add name="UspSqlRoleManager" type="System.Web.Security.SqlRoleProvider" connectionStringName="UspSecurityConnectionString" applicationName="SecurityTutorials"/> </providers> </roleManager> </system.web>Meine Konfiguration auf Seiten des Clients:
Binding.Security.Mode = SecurityMode.Message; Binding.Security.Message.ClientCredentialType = MessageCredentialType.UserName; Binding.SendTimeout.Add(new TimeSpan(0, 2, 0)); Binding.ReceiveTimeout.Add(new TimeSpan(24, 0, 0, 0)); Binding.ReliableSession.InactivityTimeout.Add( new TimeSpan(9, 0, 0)); Binding.ReliableSession.Enabled = false; Binding.CreateBindingElements();
EndpointIdentity endpointIdentity = EndpointIdentity.CreateDnsIdentity("localhost"); System.ServiceModel.Channels.AddressHeader addressHeader =
System.ServiceModel.Channels.AddressHeader.CreateAddressHeader("OpcUaConnection",
"net.tcp://localhost:[port]/UspService/OpcUaClient",1); EndpointAddress connectionAddress = new EndpointAddress(new Uri(ResourceValue.sNetTCP + StaticsHmi.serviceList[StaticsHmi.ListNumWcfServer].ListServices[j].Ip.ToString() + ":" + StaticsHmi.serviceList[StaticsHmi.ListNumWcfServer].ListServices[j].Port.ToString() + ResourceValue.sOpcUaClient), endpointIdentity, addressHeader); StaticsHmi.opcUaProxy = new ConnectionClient(Binding, connectionAddress); StaticsHmi.opcUaProxy.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode =
System.ServiceModel.Security.X509CertificateValidationMode.PeerTrust; StaticsHmi.opcUaProxy.ClientCredentials.ServiceCertificate.Authentication.TrustedStoreLocation =
System.Security.Cryptography.X509Certificates.StoreLocation.LocalMachine; StaticsHmi.opcUaProxy.ClientCredentials.UserName.UserName = StaticsHmi.userName; StaticsHmi.opcUaProxy.ClientCredentials.UserName.Password = StaticsHmi.userPwd; StaticsHmi.opcUaProxy.Open();
Ich habe schon mehrere Foren Einträge zu diesem Thema gelesen sowie in Literatur nach einer Lösung gesucht. Ich hoffe, dass ihr mir weiter helfen könnt.
Grüße
Michael
- Editado Michael_F85 lunes, 23 de mayo de 2011 9:07 formatierung
Todas las respuestas
-
miércoles, 01 de junio de 2011 9:28
Funktioniert das auch nicht, wenn Client und Server die selbe Maschine ist?
- Editado Marco Pangritz viernes, 03 de junio de 2011 6:49
- Editado Marco Pangritz viernes, 03 de junio de 2011 6:50
-
viernes, 03 de junio de 2011 6:32Das Funktioniert auch nicht wenn Client und Server auf der selben Maschine betrieben wird.
-
viernes, 03 de junio de 2011 6:56
Teste mal im Client anstatt StaticsHmi.opcUaProxy.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = PeerTrust den PeerOrChainTrust oder None Modus.
-
viernes, 03 de junio de 2011 8:06Dies hatte ich leider ohne Erfolg schon versucht, der Fehler bleibt bestehen.

