I hope that I get all the steps correct to explain what I did. In summary I created my on certificates to develop and test a self hosted WCF using SSL.
1) i create the CA
2) I moved that CA to the Certificates Trusted Root Authority
3) I created a self signed certificate from the CA i created
4) I wrote my WCF and Self hosted it.
5) I wrote a console app and added a service reference to service in step 4 and ran the app and it worked! Cool.
6) I wrote and new console app but did not add a service reference. I wrote my own code to call the self hosted WCF but I get a timeout. Below is the code that times out. The error is {"The operation has timed out"}.
my x509 certificate path is to the self signed file that I exported from mmc.
All help with this is greatly appreciated.
1) i create the CA
2) I moved that CA to the Certificates Trusted Root Authority
3) I created a self signed certificate from the CA i created
4) I wrote my WCF and Self hosted it.
5) I wrote a console app and added a service reference to service in step 4 and ran the app and it worked! Cool.
6) I wrote and new console app but did not add a service reference. I wrote my own code to call the self hosted WCF but I get a timeout. Below is the code that times out. The error is {"The operation has timed out"}.
my x509 certificate path is to the self signed file that I exported from mmc.
VB.NET:
Imports System.Net
Imports System.IO
Imports System.Security.Cryptography.X509Certificates
Module Module1
Sub Main()
Dim webRequest As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://localhost:10991/WCFCalculator")
webRequest.Method = "POST"
webRequest.ContentType = "text/xml; charset=utf-8"
Dim content = "<s:Envelope xmlns:s=""http://schemas.xmlsoap.org/soap/envelope/""><s:Body><add xmlns=""http://Microsoft.ServiceModel.Samples""><a1>1</a1><a2>1</a2></add></s:Body></s:Envelope>"
webRequest.ContentLength = content.Length
webRequest.ClientCertificates.Add(New X509Certificate2("C:\TestData\ssl\exportedGary1.pfx", "Kangaroo", X509KeyStorageFlags.MachineKeySet))
webRequest.Timeout = 10000
webRequest.Headers.Add("SOAPAction", "http://Microsoft.ServiceModel.Samples/IWCFCalculator/add")
Using sw As New StreamWriter(webRequest.GetRequestStream())
sw.Write(content)
End Using
Using sr As New System.IO.StreamReader(webRequest.GetResponse().GetResponseStream)
Dim data = sr.ReadToEnd
Console.WriteLine(data)
Console.Read()
End Using
End Sub
End Module
All help with this is greatly appreciated.