github.com/Night-mk/quorum@v21.1.0+incompatible/plugin/verifier.go (about)

     1  package plugin
     2  
     3  import (
     4  	"fmt"
     5  	"path"
     6  
     7  	"github.com/ethereum/go-ethereum/log"
     8  )
     9  
    10  // Plugin Integrity Verifier.
    11  // Verifier works on the assumption an attacker can not compromise the integrity of geth running process.
    12  type Verifier interface {
    13  	// verify plugin signature using checksum & pgp public key
    14  	VerifySignature(definition *PluginDefinition, checksum string) error
    15  }
    16  
    17  type NonVerifier struct {
    18  }
    19  
    20  func (*NonVerifier) VerifySignature(definition *PluginDefinition, checksum string) error {
    21  	return nil
    22  }
    23  
    24  func NewNonVerifier() *NonVerifier {
    25  	return &NonVerifier{}
    26  }
    27  
    28  func NewVerifier(pm *PluginManager, localVerify bool, publicKey string) (Verifier, error) {
    29  	log.Debug("using verifier", "local", localVerify)
    30  	pluginBaseDir := pm.pluginBaseDir
    31  	centralClient := pm.centralClient
    32  	// resolve public key
    33  	if publicKey == "" {
    34  		publicKey = fmt.Sprintf("file://%s", path.Join(pluginBaseDir, DefaultPublicKeyFile))
    35  	}
    36  	publicKeyPath, err := resolveFilePath(publicKey)
    37  	if err != nil {
    38  		return nil, err
    39  	}
    40  	if localVerify {
    41  		return NewLocalVerifier(publicKeyPath, pluginBaseDir)
    42  	} else {
    43  		return NewOnlineVerifier(centralClient), nil
    44  	}
    45  }