Create a self signed SSL certificate

Create and install a self signed SSL certificate (with the SelfSSL7 utility)


SelfSSL - Create and install a self signed SSL certificate.
File Name  : SelfSSL.ps1
Author     : Fabrice ZERROUKI -
PS D:\>SelfSSL.ps1
[Parameter(Mandatory=$true, HelpMessage="You must provide a website name.")]

$IPAddress = Get-WmiObject Win32_NetworkAdapterConfiguration | Where { $_.DefaultIPGateway -ne $null } -ErrorAction SilentlyContinue
$IP = $IPAddress | % {$_.IPAddress}
if(!(Test-Path $TempFolder)) {New-Item -Path $TempFolder -Type directory}

Function Unzip($ZipFile, $UnzipPath) {
$ShellApplication = New-Object -com Shell.Application
$ZipPackage = $ShellApplication.NameSpace($ZipFile)
$DestFolder = $ShellApplication.NameSpace($UnzipPath)

if (!(Test-Path ($SelfSSL7))) {
# Download the SelfSSL7 utility
Write-Host "Downloading selfssl7 utility..." -ForegroundColor DarkGreen;
$src = ""
$wc = New-Object System.Net.WebClient
# Uncomment the next 2 lines if you have to use the IE configured proxy
#$wc.UseDefaultCredentials = $true
#$wc.Proxy.Credentials = $wc.Credentials
$wc.DownloadFile($src, $dest)
# Unzip the downloaded file
Write-Host "Extracting selfssl7 utility..." -ForegroundColor DarkGreen;
UnZip $dest $TempFolder

$args = " /N cn=$env:COMPUTERNAME /K 2048 /V 365 /I /S $Website /P443 /A $IP /T"
Start-Process -FilePath $SelfSSL7 -ArgumentList $args -Wait

Write-Host "`nSelf Signed SSL certificate for website $Website successfully created and installed!" -ForegroundColor DarkGreen;
Remove-Item $TempFolder -recurse

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top