CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
X509.SSLOptions Class Reference

Public Member Functions

def __init__ (self, proxy_only=False)
 

Public Attributes

 ca_path
 
 cert_file
 
 key_file
 
 key_pass
 

Detailed Description

Captures standard SSL X509 client parametres.

Grab standard grid certificate environment into easier to access
fields: ``ca_path``, ``key_file``, ``cert_file`` and ``key_pass``.

Typically ``ca_path`` will be taken from $X509_CERT_DIR environment
variable, and ``key_file`` and ``cert_file`` from either
$X509_USER_PROXY or $X509_USER_CERT and $X509_USER_KEY environment
variables.

If the key file looks like it's a private key rather than a proxy,
i.e. key and cert files are different paths, the class constructor
will prompt the user for the key password. That password should be
offered to lower level HTTP library as the key password so it will
not prompt again. Note that the standard python ssl library cannot
take password as an argument, only the curl one can. In other words
you should probably use the curl library if you use this class and
it's possible the user supplies real key/cert rather than proxy.

If the environment variables are not set, the following defaults
are checked for existence:

* $X509_CERT_DIR: /etc/grid-security/certificates
* $X509_USER_KEY: $HOME/.globus/userkey.pem
* $X509_USER_CERT: $HOME/.globus/usercert.pem

If neither the standard environment variables nor the default path
locations exist, the constructor throws an exception.

Definition at line 5 of file X509.py.

Constructor & Destructor Documentation

def X509.SSLOptions.__init__ (   self,
  proxy_only = False 
)
Initialise the SSL X509 options. If `proxy_only`, will never
prompt for password even if key and cert files are separate, on
the assumption this will only ever be used with proxies.

Definition at line 34 of file X509.py.

34  def __init__(self, proxy_only = False):
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."""
38  self.key_file = None
39  self.cert_file = None
40  self.ca_path = None
41  self.key_pass = None
42 
43  path = os.getenv("X509_CERT_DIR", None)
44  if path and os.path.exists(path):
45  self.ca_path = path
46 
47  if not self.ca_path:
48  path = "/etc/grid-security/certificates"
49  if os.path.exists(path):
50  self.ca_path = path
51 
52  path = os.getenv("X509_USER_PROXY", None)
53  if path and os.path.exists(path):
54  self.key_file = self.cert_file = path
55 
56  if not self.key_file:
57  path = os.getenv("X509_USER_KEY", None)
58  if path and os.path.exists(path):
59  self.key_file = path
60 
61  if not self.cert_file:
62  path = os.getenv("X509_USER_CERT", None)
63  if path and os.path.exists(path):
64  self.cert_file = path
65 
66  if not self.key_file:
67  path = os.getenv("HOME") + "/.globus/userkey.pem"
68  if os.path.exists(path):
69  self.key_file = path
70 
71  if not self.cert_file:
72  path = os.getenv("HOME") + "/.globus/usercert.pem"
73  if os.path.exists(path):
74  self.cert_file = path
75 
76  if not self.ca_path or not os.path.exists(self.ca_path):
77  raise RuntimeError("no certificate directory found")
78 
79  if not self.key_file or not os.path.exists(self.key_file):
80  raise RuntimeError("no certificate private key file found")
81 
82  if not self.cert_file or not os.path.exists(self.cert_file):
83  raise RuntimeError("no certificate public key file found")
84 
85  if not proxy_only and self.key_file != self.cert_file:
86  self.key_pass = getpass("Password for %s: " % self.key_file)
87 
88 
def __init__(self, proxy_only=False)
Definition: X509.py:34

Member Data Documentation

X509.SSLOptions.ca_path

Definition at line 40 of file X509.py.

X509.SSLOptions.cert_file

Definition at line 39 of file X509.py.

X509.SSLOptions.key_file

Definition at line 38 of file X509.py.

X509.SSLOptions.key_pass

Definition at line 41 of file X509.py.