i have a wcf rest service hosted on iis which is ssl enabled. i have both a console application and a browser as client. Is it possible to implement ssl on the console app? is possible, any idea or links to related resources will be greatly helpful.
Asked
Active
Viewed 362 times
1 Answers
0
If you want to use mutual SSL with a REST service from your console application, you can use the WebChannelFactory
class.
http://msdn.microsoft.com/en-us/library/bb908674.aspx
The client certificate is set using the WebChannelFactory.Credentials
property. The advantage of this approach is that you can set the certificate in connnnfiguration so you can change it later without recompiling.
Alternatively, you can use the HttpWebRequest
class and its ClientCertificates
property.

Mike Goodwin
- 8,810
- 2
- 35
- 50
-
Instead of using webclient, i wanted to work with the basics first.I am using httpwebrequest and httpwebresponse classes. It will be helpful if you could clarify more or provide some links to related resources.If i want to enable ssl on the console app(so that the server knows it is the actual client it is talking to), how do i do that? what are the classes and libraries in C# that deals with ssl. – Rain Apr 29 '12 at 09:10
-
Do you mean you want to do mutual SSL between the client and server? – Mike Goodwin Apr 29 '12 at 09:16
-
also i get the following error when i host my service in a console application.HTTP could not register URL https://+:443/Service1.svc/ because TCP port 443 is being used by another application. – Rain Apr 29 '12 at 10:47
-
That sounds like you are *hosting* the service in your console app. I understood from your question that the service was hosted in IIS and the console app was the client? If you try to host the service in a console app ona machine that has IIS on it, you will usually need to specify an alternative port because IIS will be listening for HTTPS traffic on port 443. – Mike Goodwin Apr 29 '12 at 11:54
-
Thanks a lot Mike. It worked. Just very much amazed to see that if one wants a ssl enabled service and not the client, configuring the service does it all. But does does all the inner workings of ssl happen? this is something i really need to look upon. Thanks again. – Rain Apr 29 '12 at 15:48
-
My service(ssl+basic) and client(browser) are working properly.but authentication is done for all the requests(GET,PUT,POST,DELETE). However i want that authentication should be done for all except GET. How do i do that? – Rain Apr 29 '12 at 21:45
-
-
The authentication scheme in WCF is specified at the service level so you can't pick which verbs you want to apply it to. You could place the GET in a different service... – Mike Goodwin Apr 30 '12 at 19:15