-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/tailscale/cli: make "update" work on Windows
Updates #6995 Co-authored-by: Aaron Klotz <aaron@tailscale.com> Change-Id: I16622f43156a70b6fbc8205239fd489d7378d57b Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
- Loading branch information
Showing
4 changed files
with
347 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* SPDX-License-Identifier: MIT | ||
* | ||
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved. | ||
*/ | ||
|
||
package cli | ||
|
||
import ( | ||
"unsafe" | ||
|
||
"golang.org/x/sys/windows" | ||
) | ||
|
||
func init() { | ||
verifyAuthenticode = verifyAuthenticodeWindows | ||
} | ||
|
||
func verifyAuthenticodeWindows(path string) error { | ||
path16, err := windows.UTF16PtrFromString(path) | ||
if err != nil { | ||
return err | ||
} | ||
data := &windows.WinTrustData{ | ||
Size: uint32(unsafe.Sizeof(windows.WinTrustData{})), | ||
UIChoice: windows.WTD_UI_NONE, | ||
RevocationChecks: windows.WTD_REVOKE_WHOLECHAIN, // Full revocation checking, as this is called with network connectivity. | ||
UnionChoice: windows.WTD_CHOICE_FILE, | ||
StateAction: windows.WTD_STATEACTION_VERIFY, | ||
FileOrCatalogOrBlobOrSgnrOrCert: unsafe.Pointer(&windows.WinTrustFileInfo{ | ||
Size: uint32(unsafe.Sizeof(windows.WinTrustFileInfo{})), | ||
FilePath: path16, | ||
}), | ||
} | ||
err = windows.WinVerifyTrustEx(windows.InvalidHWND, &windows.WINTRUST_ACTION_GENERIC_VERIFY_V2, data) | ||
data.StateAction = windows.WTD_STATEACTION_CLOSE | ||
windows.WinVerifyTrustEx(windows.InvalidHWND, &windows.WINTRUST_ACTION_GENERIC_VERIFY_V2, data) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.