Skip to content

Commit b1df256

Browse files
author
Tyler Applebaum
committed
Update Invoke-BinarySignature.psm1
1 parent 6377b3d commit b1df256

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Invoke-BinarySignature.psm1

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ Function Get-TimeStampServer {
22
[CmdletBinding()]
33
Param(
44
[Parameter(HelpMessage="List of known good timestamp servers")]
5-
$TimeStampServers = @("http://ca.signfiles.com/tsa/get.aspx","http://timestamp.globalsign.com/scripts/timstamp.dll")
5+
$TimeStampServers = @("http://timestamp.globalsign.com/scripts/timstamp.dll","http://ca.signfiles.com/tsa/get.aspx")
66
)
77
$TimeStampHostnames = $TimeStampServers -Replace("^http:\/\/","") -Replace ("\/.*","") #Isolate hostnames for Test-NetConnection
88
$Count = ($TimeStampHostnames.Count - 1)
99
For ($i = 0; $i -le $Count; $i++) {
1010
Try {
1111
If ([bool](Test-NetConnection $TimeStampHostnames[$i] -Port 80 | Select-Object -ExpandProperty TcpTestSucceeded)) {
1212
Write-Verbose "$($TimeStampHostnames[$i]) selected"
13-
$TimeStampServer = $TimeStampServers[$i]
13+
$script:TimeStampServer = $TimeStampServers[$i]
1414
Break #Once we find a valid server, stop looking.
1515
}
1616
}
@@ -46,6 +46,12 @@ Param(
4646
$CertFriendlyName = $PSBoundParameters.CodeSigningCertName
4747
}
4848
Process {
49+
Try {
50+
Get-TimeStampServer
51+
}
52+
Catch {
53+
Write-Error "TimeStampServer could not be reached"
54+
}
4955
Write-Verbose $CertFriendlyName
5056
$CodeSigningCert = Get-ChildItem Cert:\CurrentUser\My | Where-Object FriendlyName -like $CertFriendlyName
5157
Set-AuthenticodeSignature -Certificate $CodeSigningCert -TimestampServer $TimeStampServer -HashAlgorithm SHA256 -FilePath $BinPath

0 commit comments

Comments
 (0)