Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions pkg/sys/trust.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"io"
"os"
"reflect"
"runtime"
"sync"
"time"
"unsafe"
Expand Down Expand Up @@ -310,8 +309,6 @@ func NewCatalog() Cat {
// Open opens the catalog and acquires the hash for the given file. If the
// file is catalog-signed, a valid catalog handle is stored internally.
func (c *Cat) Open(filename string) error {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
// acquire handle to a catalog administrator context
err := CryptCatalogAdminAcquireContext(&c.admin, nil, nil, 0, 0)
if err != nil {
Expand Down Expand Up @@ -350,8 +347,6 @@ func (c *Cat) IsCatalogSigned() bool {

// Verify verifies the signature of the given file against the catalog.
func (c *Cat) Verify(filename string) (SignatureStatus, error) {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
trust := NewWintrustData(WtdChoiceCatalog)
defer trust.Close()
if c.file == nil {
Expand Down Expand Up @@ -428,8 +423,6 @@ func (c *Cat) ParseCertificate() (*Cert, error) {
}

func (c *Cat) Close() error {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
if c.admin != 0 {
defer CryptCatalogAdminReleaseContext(c.admin, 0)
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/util/signature/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,11 @@ func (s *Signatures) getOrCheck(key Key) *Signature {
}

func (s *Signatures) runWorker() {
// pin this goroutine to its OS thread for the lifetime of the worker.
// WinVerifyTrust has COM STA thread affinity and all calls must happen
// on a thread where CoInitializeEx has been called.
runtime.LockOSThread()
defer runtime.UnlockOSThread()
for {
select {
case req := <-s.requests:
Expand Down
3 changes: 0 additions & 3 deletions pkg/util/signature/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package signature
import (
"errors"
"fmt"
"runtime"
"sync/atomic"
"time"

Expand Down Expand Up @@ -262,8 +261,6 @@ func (s *Signature) HasCertificate() bool {
// by passing the inquiry to a trust provider that supports the action
// identifier.
func (s *Signature) verifyFile() error {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
trust := sys.NewWintrustData(sys.WtdChoiceFile)
defer trust.Close()
status, err := trust.VerifyFile(s.Path)
Expand Down
Loading