EDN Admin
Well-known member
Hi,
I am developing a web service in WCF and I found a way to secure it using SSL self-signed certificate.
This web service will be hosted on a Windows 7 PC (not a windows server with IIS) and it will be a stand alone hosted service.
The web service is started from a console application like this :
<div style="color:black; background-color:white
<pre><span style="color:blue using System;
<span style="color:blue using System.Collections.Generic;
<span style="color:blue using System.Linq;
<span style="color:blue using System.Text;
<span style="color:blue using System.ServiceModel;
<span style="color:blue using EvalServiceLibrary;
<span style="color:blue namespace EvalServiceWCFServer
{
<span style="color:blue class Program
{
<span style="color:blue static <span style="color:blue void Main(<span style="color:blue string[] args)
{
ServiceHost sh = <span style="color:blue new ServiceHost(<span style="color:blue typeof(EvalService));
sh.Open();
Console.WriteLine(<span style="color:#a31515 "Service is up and running at {0}", sh.Description.Endpoints[0].ListenUri.AbsoluteUri);
Console.WriteLine(<span style="color:#a31515 "Press any key to exit the service ...");
Console.ReadKey();
sh.Close();
}
}
}
[/code]
When the application is ran, it looks like this:<br/>
http://img827.imageshack.us/img827/8949/unledbbg.jpg" target="_blank http://img827.imageshack.us/img827/8949/unledbbg.jpg
My EvalServiceWCFServer.exe (console app) uses the following
App.config :<br/>
http://pastebin.com/VSudup9q" target="_blank http://pastebin.com/VSudup9q
So, when I visit this URL https://localhost:9000/EvalService/ in my browser, I can see that, locally the web service is running fine on
HTTPS protocol as intended:<br/>
http://img827.imageshack.us/img827/8949/unledbbg.jpg" target="_blank http://img827.imageshack.us/img827/8949/unledbbg.jpg
To install the self-signed SSL Certificate on port 9000 , this is what I did in
Command Prompt :
<pre style="color:#cc0000 makecert -sv SignRoot.pvk -cy authority -r signroot.cer -a sha1 -n "CN=Dev Certification Authority" -ss root -sr localmachine[/code]
<pre style="color:#0000ff <br/>makecert -iv SignRoot.pvk -ic signroot.cer -cy end -pe -n CN="localhost" -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localmachine -sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12[/code]
<pre style="color:#008000 <br/>netsh http add sslcert ipport=0.0.0.0:9000 certhash=d9aef8055c115d9cbd6a9d6f2bdbb64bfbe62562 appid={00112233-4455-6677-8899-AABBCCDDEEFF}[/code]
<br/>
Our network is behind a DrayTek router, so what I have done is did a Port Redirection to our
public_wan_external_ip:9000 to my local_pc_ip:9000 like this:<br/>
http://img268.imageshack.us/img268/9624/unledltx.jpg" target="_blank http://img268.imageshack.us/img268/9624/unledltx.jpg
So, if I were to visit this URL https://94.30.XXX.XXX:9000/EvalService/ I should see the web service (like when I saw it on the localhost URL), but instead its not working.
What am I doing wrong here? Sorry I am very new to WCF web service. I need this web service available via a public wan external IP over HTTPS protocol.
Please advice, thanks in advance for any help / tip.
Regards,<br/>
Latheesan K
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
View the full article
I am developing a web service in WCF and I found a way to secure it using SSL self-signed certificate.
This web service will be hosted on a Windows 7 PC (not a windows server with IIS) and it will be a stand alone hosted service.
The web service is started from a console application like this :
<div style="color:black; background-color:white
<pre><span style="color:blue using System;
<span style="color:blue using System.Collections.Generic;
<span style="color:blue using System.Linq;
<span style="color:blue using System.Text;
<span style="color:blue using System.ServiceModel;
<span style="color:blue using EvalServiceLibrary;
<span style="color:blue namespace EvalServiceWCFServer
{
<span style="color:blue class Program
{
<span style="color:blue static <span style="color:blue void Main(<span style="color:blue string[] args)
{
ServiceHost sh = <span style="color:blue new ServiceHost(<span style="color:blue typeof(EvalService));
sh.Open();
Console.WriteLine(<span style="color:#a31515 "Service is up and running at {0}", sh.Description.Endpoints[0].ListenUri.AbsoluteUri);
Console.WriteLine(<span style="color:#a31515 "Press any key to exit the service ...");
Console.ReadKey();
sh.Close();
}
}
}
[/code]
When the application is ran, it looks like this:<br/>
http://img827.imageshack.us/img827/8949/unledbbg.jpg" target="_blank http://img827.imageshack.us/img827/8949/unledbbg.jpg
My EvalServiceWCFServer.exe (console app) uses the following
App.config :<br/>
http://pastebin.com/VSudup9q" target="_blank http://pastebin.com/VSudup9q
So, when I visit this URL https://localhost:9000/EvalService/ in my browser, I can see that, locally the web service is running fine on
HTTPS protocol as intended:<br/>
http://img827.imageshack.us/img827/8949/unledbbg.jpg" target="_blank http://img827.imageshack.us/img827/8949/unledbbg.jpg
To install the self-signed SSL Certificate on port 9000 , this is what I did in
Command Prompt :
<pre style="color:#cc0000 makecert -sv SignRoot.pvk -cy authority -r signroot.cer -a sha1 -n "CN=Dev Certification Authority" -ss root -sr localmachine[/code]
<pre style="color:#0000ff <br/>makecert -iv SignRoot.pvk -ic signroot.cer -cy end -pe -n CN="localhost" -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localmachine -sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12[/code]
<pre style="color:#008000 <br/>netsh http add sslcert ipport=0.0.0.0:9000 certhash=d9aef8055c115d9cbd6a9d6f2bdbb64bfbe62562 appid={00112233-4455-6677-8899-AABBCCDDEEFF}[/code]
<br/>
Our network is behind a DrayTek router, so what I have done is did a Port Redirection to our
public_wan_external_ip:9000 to my local_pc_ip:9000 like this:<br/>
http://img268.imageshack.us/img268/9624/unledltx.jpg" target="_blank http://img268.imageshack.us/img268/9624/unledltx.jpg
So, if I were to visit this URL https://94.30.XXX.XXX:9000/EvalService/ I should see the web service (like when I saw it on the localhost URL), but instead its not working.
What am I doing wrong here? Sorry I am very new to WCF web service. I need this web service available via a public wan external IP over HTTPS protocol.
Please advice, thanks in advance for any help / tip.
Regards,<br/>
Latheesan K
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
View the full article