Click here to Skip to main content
15,037,009 members
Articles / Programming Languages / Visual Basic 10

Stats

5.9K views
184 downloads
11 bookmarked

Hosted WCF Service over HTTPS

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
27 May 2019CPOL3 min read
Example of a self hosted WCF service over HTTPS with transaction
::
:: This script creates a self-signed certificate, and registers that certificate with port 44400
::

:: Create self-signed certificate for localhost and computer name in store Local Computer/Personal (=My) and file localhost.cer.
"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\makecert" -r -sk %computername% -sr LocalMachine -ss My -n CN=%computername%,CN=localhost,CN=%computername% c:\localhost.cer

:: Make certificate trusted by importing localhost.cer to store Computer/Trusted People
certutil -addstore TrustedPeople c:\localhost.cer

:: Delete certificate file c:\localhost.cer
del c:\localhost.cer

@echo off

:: Get the certificate Thumbprint: 
for /F "tokens=3" %%x in ('certutil -store My %computername% ^| find "Cert Hash(sha1):"') do (set Hash=%%x)
echo Created certificate with thumbprint=%Hash%

@echo on

:: Unbind any certificate from port 44400
netsh http delete sslcert ipport=0.0.0.0:44400

:: Bind certificate to port 44400
netsh http add sslcert ipport=0.0.0.0:44400 certhash=%Hash% appid={12345678-1234-1234-1234-123456789012}

pause

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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

Share

About the Author

Alexandros Pappas
Software Developer (Senior) Unisystems
Greece Greece
No Biography provided

Comments and Discussions