Skip to content

Commit 26a7b71

Browse files
committed
Fix file name to handle wildcard certificates
1 parent bde101c commit 26a7b71

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Request-Certificate.ps1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,9 @@ CertificateTemplate = "$TemplateName"
275275
#create temp files
276276
$inf = [System.IO.Path]::GetTempFileName()
277277
$req = [System.IO.Path]::GetTempFileName()
278-
$cer = Join-Path -Path $env:TEMP -ChildPath "$CN.cer"
279-
$rsp = Join-Path -Path $env:TEMP -ChildPath "$CN.rsp"
278+
$filename = $CN -replace "^\*","wildcard"
279+
$cer = Join-Path -Path $env:TEMP -ChildPath "$filename.cer"
280+
$rsp = Join-Path -Path $env:TEMP -ChildPath "$filename.rsp"
280281

281282
Remove-ReqTempfiles -tempfiles $inf, $req, $cer, $rsp
282283

@@ -356,10 +357,10 @@ CertificateTemplate = "$TemplateName"
356357

357358
#write pfx file
358359
if ($PSBoundParameters.ContainsKey('ExportPath')) {
359-
$pfxPath = Join-Path -Path (Resolve-Path -Path $ExportPath) -ChildPath "$CN.pfx"
360+
$pfxPath = Join-Path -Path (Resolve-Path -Path $ExportPath) -ChildPath "$filename.pfx"
360361
}
361362
else {
362-
$pfxPath = ".\$CN.pfx"
363+
$pfxPath = ".\$filename.pfx"
363364
}
364365
$certbytes | Set-Content -Encoding Byte -Path $pfxPath -ea Stop
365366
Write-Host "Certificate successfully exported to `"$pfxPath`"!" -ForegroundColor Green

0 commit comments

Comments
 (0)