Public/New-SifCerts.ps1
function New-SifCerts { param ( [Parameter(Mandatory=$true, Position=0)] [string] $RootCertName, [Parameter(Mandatory=$true, Position=0)] [string] $ClientCertName, [Parameter(Mandatory=$true, Position=0)] [string] $ServerCertName, [Parameter(Mandatory=$true, Position=0)] [string] $SaveCertPath ) # create a root certificate $newRootCertResult = New-RootCertificate -Path $SaveCertPath -Name $RootCertName -DnsName $RootCertName $importCertResult = Import-Certificate -FilePath $newRootCertResult.FileInfo.Fullname -CertStoreLocation Cert:\LocalMachine\Root $newClientCertInfo = New-SelfSignedCertificate -Path $SaveCertPath -Signer $newRootCertResult.Certificate -Name $ClientCertName -DnsName $ClientCertName $newServerCertInfo = New-SelfSignedCertificate -Path $SaveCertPath -Signer $newRootCertResult.Certificate -Name $ServerCertName -DnsName $ServerCertName $result = @{ NewRootCertResult = $newRootCertResult ImportCertRsult = $importCertResult ClientCert = $newClientCertInfo ServerCert = $newServerCertInfo } return $result } |