I developed the Client / Server application for my current employer, and one of the requirements is that the client part will be distributed as a DLL. Since DLLs do not "make" dllName.dll.config, I need to move the config to the code. I did it to the best of my ability, but now I get this exception;
Failed to get X.509 CN certificate = ComputerName circuit integrity.
The certificate used has a chain of trust that cannot be verified. Replace the certificate or change certificateValidationMode. An internal certificate integrity error has occurred.
I have googled, and otherwise I was looking for everything to solve this problem, but so far I can not find anything with an explicit sufficient explanation of the various solutions that I saw in the near future, but not in reality.
In any case, there is a certificate in My LocalStore, but it is really used only by the server (it is currently testing both the client and the server in the same XP Pro window), at least as far as I understand. (Still quite new to WCF) (note how the client configuration file below does not receive or otherwise points to the above certificate to the client at all.
The app.config client looks like this and works great with our test EXE, which contains a section of this configuration file.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="MyTcpBinding_IFileXferService"
receiveTimeout="02:00:00"
sendTimeout="02:00:00"
transferMode="Streamed"
maxBufferSize="65536"
maxReceivedMessageSize="2147483647">
<readerQuotas maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="65536" />
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="ClientConfigBehavior">
<dataContractSerializer maxItemsInObjectGraph="6553600" />
<clientCredentials>
<serviceCertificate>
<authentication certificateValidationMode="None" />
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint name="ClientConfig"
binding="netTcpBinding"
bindingConfiguration="MyTcpBinding_IFileXferService"
behaviorConfiguration="ClientConfigBehavior"
contract="ServiceRefs.IFileXferService" />
</client>
</system.serviceModel>
</configuration>
, ( DLL .config), , . (, , , xml.)
, , :
...
netTcpBinding = new NetTcpBinding();
endpointAddr = new EndpointAddress(HostURI);
updateMaxItemsBehavior();
TimeSpan tsTwoHours = new TimeSpan(2,0,0);
netTcpBinding.ReceiveTimeout = tsTwoHours;
netTcpBinding.SendTimeout = tsTwoHours;
netTcpBinding.TransferMode = TransferMode.Streamed;
netTcpBinding.MaxBufferSize = 65536;
netTcpBinding.MaxReceivedMessageSize = 2147483647;
netTcpBinding.ReaderQuotas.MaxStringContentLength = 2147483647;
netTcpBinding.ReaderQuotas.MaxArrayLength = 2147483647;
netTcpBinding.ReaderQuotas.MaxBytesPerRead = 65536;
netTcpBinding.MaxBufferPoolSize = 131072;
netTcpBinding.Security.Mode = SecurityMode.Transport;
netTcpBinding.Security.Transport.ClientCredentialType =
TcpClientCredentialType.None;
svcClient = new FileXferServiceClient(netTcpBinding, endpointAddr);
,
dang.
X509Certificate2 cert = new X509Certificate2();
svcClient.ClientCredentials.ClientCertificate.Certificate = cert;
private void updateMaxItemsBehavior()
{
svcEndpoint = new ServiceEndpoint(
new ContractDescription("IFileXferService"));
foreach (OperationDescription operation in
svcEndpoint.Contract.Operations)
{
operation.Behaviors
.Find<DataContractSerializerOperationBehavior>()
.MaxItemsInObjectGraph = 6553600;
}
}
, Winforms (, , WCF) wfappname.exe.config, , , -, . , , " app.config , WCF- app.config. '
- ? ( !); )
,