3 from getpass
import getpass
6 """Captures standard SSL X509 client parametres. 8 Grab standard grid certificate environment into easier to access 9 fields: ``ca_path``, ``key_file``, ``cert_file`` and ``key_pass``. 11 Typically ``ca_path`` will be taken from $X509_CERT_DIR environment 12 variable, and ``key_file`` and ``cert_file`` from either 13 $X509_USER_PROXY or $X509_USER_CERT and $X509_USER_KEY environment 16 If the key file looks like it's a private key rather than a proxy, 17 i.e. key and cert files are different paths, the class constructor 18 will prompt the user for the key password. That password should be 19 offered to lower level HTTP library as the key password so it will 20 not prompt again. Note that the standard python ssl library cannot 21 take password as an argument, only the curl one can. In other words 22 you should probably use the curl library if you use this class and 23 it's possible the user supplies real key/cert rather than proxy. 25 If the environment variables are not set, the following defaults 26 are checked for existence: 28 * $X509_CERT_DIR: /etc/grid-security/certificates 29 * $X509_USER_KEY: $HOME/.globus/userkey.pem 30 * $X509_USER_CERT: $HOME/.globus/usercert.pem 32 If neither the standard environment variables nor the default path 33 locations exist, the constructor throws an exception.""" 35 """Initialise the SSL X509 options. If `proxy_only`, will never 36 prompt for password even if key and cert files are separate, on 37 the assumption this will only ever be used with proxies.""" 43 path = os.getenv(
"X509_CERT_DIR",
None)
44 if path
and os.path.exists(path):
48 path =
"/etc/grid-security/certificates" 49 if os.path.exists(path):
52 path = os.getenv(
"X509_USER_PROXY",
None)
53 if path
and os.path.exists(path):
57 path = os.getenv(
"X509_USER_KEY",
None)
58 if path
and os.path.exists(path):
62 path = os.getenv(
"X509_USER_CERT",
None)
63 if path
and os.path.exists(path):
67 path = os.getenv(
"HOME") +
"/.globus/userkey.pem" 68 if os.path.exists(path):
72 path = os.getenv(
"HOME") +
"/.globus/usercert.pem" 73 if os.path.exists(path):
77 raise RuntimeError(
"no certificate directory found")
80 raise RuntimeError(
"no certificate private key file found")
83 raise RuntimeError(
"no certificate public key file found")
def __init__(self, proxy_only=False)