How to set the GnuPG home directory within the GnuPG Python binding?

前端 未结 4 1798
悲&欢浪女
悲&欢浪女 2021-01-02 22:59

When trying to initialize the GnuPG binding in Python, I\'m getting an error message

TypeError: __init__() got an unexpected keyword argument \'gnupghome\'
<         


        
4条回答
  •  有刺的猬
    2021-01-02 23:57

    GnuPG (as command line tool) knows two ways to specify the GnuPG home directory:

    1. Using an environment variable:

      GPGHOME=C:\Users\samss\AppData\Roaming\gnupg gpg
      
    2. Passing it as a parameter (which is also available as homedir parameter in the configuration file):

      gpg --homedir=C:\Users\samss\AppData\Roaming\gnupg
      

    The GnuPG Python binding allows some parameters to be passed during initialization. Because of the initialization syntax, you probably mixed this up with the environment variable version of defining the home directory on the command line.

    An additional warning: You probably want to access another system user's GnuPG home directory. GnuPG is very picky about safe permissions. For a development machine, it might be fine to use the GnuPG parameter --no-permission-warning and privileges that allow rather broad access, but better start with a clean approach from the start and initialize a new GnuPG home directory for your application that can be properly restricted regarding permissions.

提交回复
热议问题