func (s *SecureConfig) Check(filePath string) (bool, error) {
	if len(s.Checksum) == 0 {
		return false, ErrSecureConfigNoChecksum
	}
	if s.Hash == nil {
		return false, ErrSecureConfigNoHash
	}
	file, err := os.Open(filePath)
	if err != nil {
		return false, err
	}
	defer file.Close()
	_, err = io.Copy(s.Hash, file)
	if err != nil {
		return false, err
	}
	sum := s.Hash.Sum(nil)
	return subtle.ConstantTimeCompare(sum, s.Checksum) == 1, nil
}
Check takes the filepath to an executable and returns true if the checksum of
the file matches the checksum provided in the SecureConfig.
package plugin
import (
	"bufio"
	"context"
	"crypto/subtle"
	"crypto/tls"
	"errors"
	"fmt"
	"hash"
	"io"
	"io/ioutil"
	"net"
	"os"
	"os/exec"
	"path/filepath"
	"strconv"
	"strings"
	"sync"
	"sync/atomic"
	"time"
	"unicode"
	hclog "github.com/hashicorp/go-hclog"
)
var Killed uint32 = 0
var managedClients = make([]*Client, 0, 5)
var managedClientsLock sync.Mutex
var (
	ErrProcessNotFound = errors.New("Reattachment process not found")
	ErrChecksumsDoNotMatch = errors.New("checksums did not match")
	ErrSecureConfigNoChecksum = errors.New("no checksum provided")
	ErrSecureConfigNoHash = errors.New("no hash implementation provided")
	ErrSecureConfigAndReattach = errors.New("only one of Reattach or SecureConfig can be set")
)
type Client struct {
	config      *ClientConfig
	exited      bool
	doneLogging chan struct{}
	l           sync.Mutex
	address     net.Addr
	process     *os.Process
	client      ClientProtocol
	protocol    Protocol
	logger      hclog.Logger
	doneCtx     context.Context
}
type ClientConfig struct {
	HandshakeConfig
	Plugins map[string]Plugin
	Cmd      *exec.Cmd
	Reattach *ReattachConfig
	SecureConfig *SecureConfig
	TLSConfig *tls.Config
	Managed bool
	MinPort, MaxPort uint
	StartTimeout time.Duration
	Stderr io.Writer
	SyncStdout io.Writer
	SyncStderr io.Writer
	AllowedProtocols []Protocol
	Logger hclog.Logger
}
type ReattachConfig struct {
	Protocol Protocol
	Addr     net.Addr
	Pid      int
}
type SecureConfig struct {
	Checksum []byte
	Hash     hash.Hash
}