Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET4 SOAP
Hi!
We faced the problem during creating the web service with security settings.
Certificate was received from the CA just for test purposes.
After this we did following:
1) enabling port used by the service using the httpcfg set ssl -i 0.0.0.0:777 -h
2) httpcfg set urlacl -u https://:777/TlsService/ServiceSecure -a D:(A;;GA;;;AN)
3)httpcfg set iplisten-i 0.0.0.0:777
 
The WebService code is following:
 
WSHttpBinding binding = new WSHttpBinding();
binding.Security.Mode = SecurityMode.Transport;
binding.Security.Message.ClientCredentialType = MessageCredentialType.None;
 
ServiceHost host = new ServiceHost(typeof(DeviceObservationConsumer_hostPCDData), new Uri("https://<domainname>:777/TlsService/ServiceSecure"));
host.Credentials.ServiceCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindByThumbprint, (string)"bd 35 ec c0 e6 b3 9a ac 74 09 09 c5 84 b8 fd 58 51 44 87 7d");
 
host.AddServiceEndpoint(typeof(IDeviceObservationConsumer_Binding_Soap12), binding, "");
 
ServiceMetadataBehavior smb = host.Description.Behaviors.Find<servicemetadatabehavior>();
// If not, add one
if (smb == null)
    smb = new ServiceMetadataBehavior();
smb.HttpsGetEnabled = true;
 
host.Description.Behaviors.Add(smb);
 
// Add MEX endpoint
host.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName, MetadataExchangeBindings.CreateMexHttpsBinding(), "mex");
 
host.Open();
Client code:
WSHttpBinding binding = new WSHttpBinding();
binding.Security.Mode = SecurityMode.Transport;
binding.Security.Message.ClientCredentialType = MessageCredentialType.None;
 
EndpointAddress addr = new EndpointAddress("https://<domainname>:777/TlsService/ServiceSecure");
 
ChannelFactory<deviceobservationconsumer_porttype> myChannelFactory = new ChannelFactory<deviceobservationconsumer_porttype>(binding, addr);
//myChannelFactory.Credentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindByThumbprint, (string)"bd 35 ec c0 e6 b3 9a ac 74 09 09 c5 84 b8 fd 58 51 44 87 7d");

DeviceObservationConsumer_PortType client = myChannelFactory.CreateChannel();
 
CommunicatePCDDataRequest req = new CommunicatePCDDataRequest("ciao mamma guarda come mi diverto!");
CommunicatePCDDataResponse resp = client.CommunicatePCDData(req);
 
myChannelFactory.Close();
 
We can't access the "https://<domainname>:777/TlsService/ServiceSecure" via browser and the client get the exception : An error occurred while making the HTTP request to https://<PCname>:777/TlsService/ServiceSecure. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server.
 
What we r doing wrong?
We do not using configuration file, everything is done inside the code.
 
And the
httpcfg query ssl
give as the response the following:
IP                      : 0.0.0.0:777
Hash                    : bd35ecc0e6b39aac74 9 9c584b8fd585144877d
Guid                    : {00000000-0000-0000-0000-000000000000}
CertStoreName           : MY
CertCheckMode           : 0
RevocationFreshnessTime : 0
UrlRetrievalTimeout     : 0
SslCtlIdentifier        : (null)
SslCtlStoreName         : (null)
Flags                   : 0
 
I was wondering .. the Hash is differ a bit from the one we put... the spaces presented on the response was the "0"... for some reason they were replaced... could it be the reason for the problem?
 

Any suggestion is appreciated!
 
Thanks
Liudmila
Posted 5-Aug-11 4:24am
Edited 5-Aug-11 5:42am
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Never mind.. the problem was with certificate themselves...
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 250
1 Jochen Arndt 155
2 PIEBALDconsult 150
3 DamithSL 125
4 Afzaal Ahmad Zeeshan 120
0 OriginalGriff 5,695
1 DamithSL 4,591
2 Maciej Los 4,012
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 22 Sep 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100