Changeset 6840 for TI12-security/trunk/MyProxyClient
- Timestamp:
- 23/04/10 10:16:33 (11 years ago)
- Location:
- TI12-security/trunk/MyProxyClient/myproxy
- Files:
-
- 3 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/MyProxyClient/myproxy/client.py
r6837 r6840 29 29 import re 30 30 import traceback 31 from ConfigParser import SafeConfigParser32 31 33 32 from OpenSSL import crypto, SSL 34 33 35 from myproxy.utils.openssl import OpenSSLConfig, OpenSSLConfigError 36 37 38 class CaseSensitiveConfigParser(SafeConfigParser): 39 '''Subclass the SafeConfigParser - to preserve the original string case of 40 config section names 41 ''' 42 def optionxform(self, optionstr): 43 '''Extend SafeConfigParser.optionxform to preserve case of option names 44 ''' 45 return optionstr 34 from myproxy.utils.openssl import OpenSSLConfig 35 from myproxy.utils import CaseSensitiveConfigParser 46 36 47 37 … … 64 54 PARSER_RE = re.compile(PARSER_RE_STR) 65 55 66 def __init__(self, 67 myProxyServerDN=os.environ.get('MYPROXY_SERVER_DN'), 68 cnHostPfx='host/', 69 **kw): 56 def __init__(self, myProxyServerDN=os.environ.get('MYPROXY_SERVER_DN')): 70 57 """Override parent class __init__ to enable setting of myProxyServerDN 71 58 setting … … 75 62 MyProxy server to avoid errors matching hostnames. This is useful 76 63 where the hostname is not fully qualified 77 78 @type cnHostPfx: string 79 @param cnHostPfx: globus host certificates are 80 generated by default with a 'host/' prefix to the host name. Set 81 this keyword to '' or None to override and omit the prefix""" 64 """ 82 65 83 66 # Allow for quoted DN … … 91 74 self.myProxyServerDN = zip(dnFields[1::2], dnFields[2::2]) 92 75 self.myProxyServerDN.sort() 93 self.cnHostPfx = cnHostPfx94 95 76 96 77 def __call__(self, connection, peerCert, errorStatus, errorDepth, … … 112 93 @return: status code 113 94 """ 114 return errorStatus115 116 95 if peerCert.has_expired(): 117 96 # Any expired certificate in the chain should result in an error … … 136 115 137 116 138 139 117 class MyProxyClientError(Exception): 140 118 """Base exception class for MyProxyClient exceptions""" 119 141 120 142 121 class MyProxyClientConfigError(MyProxyClientError): 143 122 """Error with configuration""" 144 123 124 145 125 class MyProxyClientGetError(MyProxyClientError): 146 126 """Exceptions arising from get request to server""" 127 147 128 148 129 class MyProxyClientRetrieveError(MyProxyClientError): 149 130 """Error recovering a response from MyProxy""" 131 150 132 151 133 class MyProxyCredentialsAlreadyExist(MyProxyClientError): … … 154 136 """ 155 137 138 156 139 class MyProxyClientGetTrustRootsError(MyProxyClientError): 157 140 """Error retrieving trust roots""" … … 209 192 created with 210 193 211 @type propertyDefaults: tuple212 @cvar propertyDefaults: sets permissable element names for MyProxy config194 @type PROPERTY_DEFAULTS: tuple 195 @cvar PROPERTY_DEFAULTS: sets permissable element names for MyProxy config 213 196 file 214 197 """ … … 219 202 PASSPHRASE=%s 220 203 LIFETIME=%d""" 221 204 205 PUT_CMD="""VERSION=MYPROXYv2 206 COMMAND=1 207 USERNAME=%s 208 PASSPHRASE=<pass phrase> 209 LIFETIME=%d""" 210 222 211 INFO_CMD="""VERSION=MYPROXYv2 223 212 COMMAND=2 … … 255 244 _hostKeySubDirPath = ('etc', 'hostkey.pem') 256 245 246 PROXY_FILE_PERMISSIONS = 0600 247 257 248 # Work out default location of proxy file if it exists. This is set if a 258 249 # call has been made previously to logon / get-delegation … … 262 253 or None) 263 254 264 PRIKEY_NBITS = 2048 #4096255 PRIKEY_NBITS = 4096 265 256 MESSAGE_DIGEST_TYPE = "md5" 266 257 SERVER_RESP_BLK_SIZE = 8192 … … 268 259 269 260 # valid configuration property keywords 270 propertyDefaults= {261 PROPERTY_DEFAULTS = { 271 262 'hostname': 'localhost', 272 263 'port': 7512, 273 264 'serverDN': '', 274 'serverCNPrefix': 'host/',275 265 'openSSLConfFilePath': '', 276 266 'proxyCertMaxLifetime': 43200, … … 282 272 # Restrict attributes to the above properties, their equivalent 283 273 # protected values + extra OpenSSL config object. 284 __slots__ = propertyDefaults.copy() 285 __slots__.update(dict([('_'+k, v) for k,v in propertyDefaults.items()] + 286 [('_openSSLConfig', None), 287 ('_cfg', None)] 288 ) 289 ) 290 274 __slots__ = tuple(['__' + k for k in PROPERTY_DEFAULTS.keys()]) 275 __slots__ += ('__openSSLConfig', '__cfg', '__serverSSLCertVerify') 276 291 277 def __init__(self, cfgFilePath=None, **prop): 292 278 """Make any initial settings for client connections to MyProxy … … 296 282 given by cfgFilePath 297 283 298 @param cfgFilePath: set properties via a configuration file 299 @param **prop: set properties via keywords - see 300 propertyDefaults class variable for a list of these 284 @param cfgFilePath: set properties via a configuration file 285 @type cfgFilePath: basestring 286 @param **prop: set properties via keywords - see 287 PROPERTY_DEFAULTS class variable for a list of these 288 @type **prop: dict 301 289 """ 302 303 # Default settings. Nb. '_' - override property methods in order to 304 # set defaults 305 for opt, val in MyProxyClient.propertyDefaults.items(): 306 setattr(self, '_'+opt, val) 290 self.__hostname = None 291 self.__port = None 292 self.__serverDN = None 293 self.__openSSLConfFilePath = None 294 self.__proxyCertMaxLifetime = MyProxyClient.PROPERTY_DEFAULTS[ 295 'proxyCertMaxLifetime'] 296 self.__proxyCertLifetime = MyProxyClient.PROPERTY_DEFAULTS[ 297 'proxyCertLifetime'] 298 self.__caCertFilePath = None 299 self.__caCertDir = None 300 301 self.__cfg = None 302 307 303 308 304 # Configuration file used to get default subject when generating a 309 305 # new proxy certificate request 310 self._ openSSLConfig = OpenSSLConfig()306 self.__openSSLConfig = OpenSSLConfig() 311 307 312 308 # Server host name - take from environment variable if available 313 309 self.hostname = os.environ.get('MYPROXY_SERVER', 314 MyProxyClient. propertyDefaults['hostname'])310 MyProxyClient.PROPERTY_DEFAULTS['hostname']) 315 311 316 312 # ... and port number 317 313 self.port = int(os.environ.get('MYPROXY_SERVER_PORT', 318 MyProxyClient. propertyDefaults['port']))314 MyProxyClient.PROPERTY_DEFAULTS['port'])) 319 315 320 316 # Server Distinguished Name 321 317 self.serverDN = os.environ.get('MYPROXY_SERVER_DN', 322 MyProxyClient. propertyDefaults['serverDN'])318 MyProxyClient.PROPERTY_DEFAULTS['serverDN']) 323 319 324 320 # Environment variable may be quoted … … 326 322 self.serverDN = self.serverDN.strip('"') 327 323 328 # keyword settings324 # Any keyword settings override the defaults above 329 325 for opt, val in prop.items(): 330 326 setattr(self, opt, val) 331 327 332 328 # If properties file is set any parameters settings in file will 333 # override those set by input keyword 329 # override those set by input keyword or the defaults 334 330 if cfgFilePath is not None: 335 331 self.parseConfig(cfg=cfgFilePath) 336 332 333 self.__serverSSLCertVerify = MyProxyServerSSLCertVerification( 334 myProxyServerDN=self.serverDN) 335 336 def _getServerSSLCertVerify(self): 337 return self.__serverSSLCertVerify 338 339 def _setServerSSLCertVerify(self, value): 340 if not isinstance(value, MyProxyServerSSLCertVerification): 341 raise TypeError('Expecting %r derived type for ' 342 '"serverSSLCertVerify" attribute; got %r' % 343 MyProxyServerSSLCertVerification, 344 value) 345 self.__serverSSLCertVerify = value 346 347 serverSSLCertVerify = property(_getServerSSLCertVerify, 348 _setServerSSLCertVerify, 349 doc="Class with a __call__ method which is " 350 "passed to the SSL context to verify " 351 "the peer (MyProxy server) certificate " 352 "in the SSL handshake between this " 353 "client and the MyProxy server") 337 354 338 355 def parseConfig(self, cfg, section='DEFAULT'): … … 341 358 if isinstance(cfg, basestring): 342 359 cfgFilePath = os.path.expandvars(cfg) 343 self._ cfg = CaseSensitiveConfigParser()344 self._ cfg.read(cfgFilePath)360 self.__cfg = CaseSensitiveConfigParser() 361 self.__cfg.read(cfgFilePath) 345 362 else: 346 363 cfgFilePath = None 347 self._ cfg = cfg348 349 for key, val in self._ cfg.items(section):364 self.__cfg = cfg 365 366 for key, val in self.__cfg.items(section): 350 367 setattr(self, key, val) 351 368 352 369 # Get/Set Property methods 353 370 def _getHostname(self): 354 return self._ hostname371 return self.__hostname 355 372 356 373 def _setHostname(self, val): … … 358 375 raise AttributeError("Expecting string type for hostname " 359 376 "attribute") 360 self._ hostname = val377 self.__hostname = val 361 378 362 379 hostname = property(fget=_getHostname, … … 365 382 366 383 def _getPort(self): 367 return self._ port384 return self.__port 368 385 369 386 def _setPort(self, val): 370 387 if isinstance(val, basestring): 371 self._ port = int(val)388 self.__port = int(val) 372 389 elif isinstance(val, int): 373 self._ port = val390 self.__port = val 374 391 else: 375 392 raise AttributeError("Expecting int type for port attribute") … … 380 397 381 398 def _getServerDN(self): 382 return self._ serverDN399 return self.__serverDN 383 400 384 401 def _setServerDN(self, val): … … 386 403 raise AttributeError("Expecting string type for serverDN " 387 404 "attribute") 388 self._ serverDN = val405 self.__serverDN = val 389 406 390 407 serverDN = property(fget=_getServerDN, … … 393 410 "Certificate") 394 411 395 def _getServerCNPrefix(self):396 return self._serverCNPrefix397 398 def _setServerCNPrefix(self, val):399 if not isinstance(val, basestring):400 raise AttributeError("Expecting string type for serverCNPrefix "401 "attribute")402 self._serverCNPrefix = val403 404 serverCNPrefix = property(fget=_getServerCNPrefix,405 fset=_setServerCNPrefix,406 doc="Prefix if any for Server Certificate DN "407 "Common Name e.g. 'host/'")408 409 412 def _getOpenSSLConfFilePath(self): 410 return self._ openSSLConfFilePath413 return self.__openSSLConfFilePath 411 414 412 415 def _setOpenSSLConfFilePath(self, val): … … 414 417 raise AttributeError("Expecting string type for " 415 418 "openSSLConfFilePath attribute") 416 self._ openSSLConfFilePath = os.path.expandvars(val)417 self._ openSSLConfig.filePath = self._openSSLConfFilePath418 self._ openSSLConfig.read()419 self.__openSSLConfFilePath = os.path.expandvars(val) 420 self.__openSSLConfig.filePath = self.__openSSLConfFilePath 421 self.__openSSLConfig.read() 419 422 420 423 openSSLConfFilePath = property(fget=_getOpenSSLConfFilePath, … … 423 426 424 427 def _getProxyCertMaxLifetime(self): 425 return self._ proxyCertMaxLifetime428 return self.__proxyCertMaxLifetime 426 429 427 430 def _setProxyCertMaxLifetime(self, val): 428 431 if isinstance(val, basestring): 429 self._ proxyCertMaxLifetime = int(val)432 self.__proxyCertMaxLifetime = int(val) 430 433 431 434 elif isinstance(val, int): 432 self._ proxyCertMaxLifetime = val435 self.__proxyCertMaxLifetime = val 433 436 else: 434 437 raise AttributeError("Expecting int type for proxyCertMaxLifetime " … … 442 445 443 446 def _getProxyCertLifetime(self): 444 return self._ proxyCertLifetime447 return self.__proxyCertLifetime 445 448 446 449 def _setProxyCertLifetime(self, val): 447 450 if isinstance(val, basestring): 448 self._ proxyCertLifetime = int(val)451 self.__proxyCertLifetime = int(val) 449 452 elif isinstance(val, int): 450 self._ proxyCertLifetime = val453 self.__proxyCertLifetime = val 451 454 else: 452 455 raise AttributeError("Expecting int type for proxyCertLifetime " … … 459 462 460 463 def _getCACertFilePath(self): 461 return self._ caCertFilePath464 return self.__caCertFilePath 462 465 463 466 def _setCACertFilePath(self, val): … … 468 471 if isinstance(val, basestring): 469 472 if val == '': 470 self._ caCertFilePath = None473 self.__caCertFilePath = None 471 474 else: 472 self._ caCertFilePath = os.path.expandvars(val)475 self.__caCertFilePath = os.path.expandvars(val) 473 476 474 477 elif isinstance(val, None): … … 483 486 484 487 def _getCACertDir(self): 485 return self._ caCertDir488 return self.__caCertDir 486 489 487 490 def _setCACertDir(self, val): … … 497 500 if isinstance(val, basestring): 498 501 if val == '': 499 self._ caCertDir = None502 self.__caCertDir = None 500 503 else: 501 self._ caCertDir = os.path.expandvars(val)504 self.__caCertDir = os.path.expandvars(val) 502 505 503 506 elif isinstance(val, None): 504 self._ caCertDir = val507 self.__caCertDir = val 505 508 else: 506 509 raise AttributeError("Expecting string or None type for caCertDir " … … 516 519 def _getOpenSSLConfig(self): 517 520 "Get OpenSSLConfig object property method" 518 return self._openSSLConfig 519 520 openSSLConfig = property(fget=_getOpenSSLConfig, 521 doc="OpenSSLConfig object") 522 523 521 return self.__openSSLConfig 522 523 openSSLConfig = property(fget=_getOpenSSLConfig, doc="OpenSSLConfig object") 524 524 525 def _initConnection(self, 525 ownerCertFile=None,526 ownerKeyFile=None,527 ownerPassphrase=None):526 certFile=None, 527 keyFile=None, 528 keyFilePassphrase=None): 528 529 """Initialise connection setting up SSL context and client and 529 530 server side identity checks 530 531 531 @type ownerCertFile: basestring532 @param ownerCertFile: client certificate and owner of credential533 to be acted on. Can be a proxy cert + proxy's signing cert. Cert534 and private key are not necessary for getDelegation / logon calls535 @type ownerKeyFile: basestring536 @ param ownerKeyFile: client private key file537 @ type ownerPassphrase: basestring538 @ param ownerPassphrase: pass-phrase protecting private key if set -539 not needed in the case of a proxy private key532 @type sslCertFile: basestring 533 @param sslCertFile: certificate for SSL client authentication. It may 534 be owner of a credential to be acted on or the concatenated proxy 535 certificate + proxy's signing cert. SSL client authentication is not 536 necessary for getDelegation / logon calls 537 @type sslKeyFile: basestring 538 @param sslKeyFile: client private key file 539 @type keyFilePassphrase: basestring 540 @param keyFilePassphrase: pass-phrase protecting private key if set 540 541 """ 541 542 # Must be version 3 for MyProxy … … 545 546 context.load_verify_locations(self.caCertFilePath, self.caCertDir) 546 547 547 if ownerCertFile:548 if certFile: 548 549 try: 549 context.use_certificate_chain_file( ownerCertFile)550 context.use_certificate_chain_file(certFile) 550 551 def pwdCallback(passphraseMaxLen, 551 552 promptPassphraseTwice, … … 559 560 return passphrase 560 561 561 context.set_passwd_cb(pwdCallback, ownerPassphrase) 562 context.use_privatekey_file(ownerKeyFile) 562 if keyFilePassphrase is not None: 563 context.set_passwd_cb(pwdCallback, keyFilePassphrase) 564 565 context.use_privatekey_file(keyFile) 563 566 except Exception: 564 567 raise MyProxyClientConfigError("Loading certificate " … … 570 573 # Verify peer's (MyProxy server) certificate 571 574 context.set_verify(SSL.VERIFY_PEER|SSL.VERIFY_FAIL_IF_NO_PEER_CERT, 572 MyProxyServerSSLCertVerification())575 self.__serverSSLCertVerify) 573 576 574 577 … … 580 583 # connect to myproxy server 581 584 conn = SSL.Connection(context, socket.socket()) 582 583 # Check server host identity - if host doesn't match use explicit584 # 'serverDN'585 # host/<hostname> one586 # hostCheck = _HostCheck(host=self.hostname,587 # myProxyServerDN=self.serverDN,588 # cnHostPfx=self.serverCNPrefix)589 # conn.set_post_connection_check_callback(hostCheck)590 585 591 586 return conn … … 699 694 700 695 return pemCerts 701 702 696 703 697 @classmethod 704 def writeProxyFile(cls,proxyCert,proxyPriKey,userX509Cert,filePath=None): 698 def writeProxyFile(cls, proxyCert, proxyPriKey, userX509Cert, 699 filePath=None): 705 700 """Write out proxy cert to file in the same way as myproxy-logon - 706 701 proxy cert, private key, user cert. Nb. output from logon can be … … 757 752 # Split certs and key into separate tuple items 758 753 return tuple(['-----BEGIN'+i for i in proxy.split('-----BEGIN')[1:]]) 759 754 755 def put(self, 756 username, 757 passphrase, 758 userCertFile, 759 userKeyFile, 760 lifetime=None, 761 sslCertFile=None, 762 sslKeyFile=None, 763 sslKeyFilePassphrase=None): 764 """Store a proxy credential on the server 765 766 @raise MyProxyClientError: no client certificate and private key set 767 768 @type username: string 769 @param username: username selected for new credential 770 @type passphrase: string 771 @param passphrase: pass-phrase for new credential. This will be used 772 by the server to authenticate later requests. 773 @type certFile: string 774 @param certFile: user's X.509 proxy certificate in PEM format 775 @type keyFile: string 776 @param keyFile: equivalent private key file in PEM format 777 @type sslCertFile: string 778 @param sslCertFile: certificate used for client authentication with 779 the MyProxy server SSL connection. This ID will be set as the owner 780 of the stored credentials. Only the owner can later remove 781 credentials with myproxy-destroy or the destroy method. If not set, 782 this argument defaults to $GLOBUS_LOCATION/etc/hostcert.pem or if this 783 is not set, certFile 784 @type sslKeyFile: string 785 @param sslKeyFile: corresponding private key file. See explanation 786 for sslCertFile 787 @type sslKeyFilePassphrase: string 788 @param sslKeyFilePassphrase: passphrase for sslKeyFile. Omit if the 789 private key is not password protected. 790 @type lifetime: int / None 791 @param lifetime: the maximum lifetime allowed for retrieved proxy 792 credentials in seconds. defaults to proxyCertMaxLifetime attribute value 793 """ 794 795 lifetime = lifetime or self.proxyCertMaxLifetime 796 797 # Inputs must be string type otherwise server will reject the request 798 if isinstance(username, unicode): 799 username = str(username) 800 801 if isinstance(passphrase, unicode): 802 passphrase = str(passphrase) 803 804 globusLoc = os.environ.get('GLOBUS_LOCATION') 805 if not sslCertFile or not sslKeyFile: 806 if globusLoc: 807 sslCertFile = os.path.join(globusLoc, 808 *MyProxyClient._hostCertSubDirPath) 809 sslKeyFile = os.path.join(globusLoc, 810 *MyProxyClient._hostKeySubDirPath) 811 else: 812 raise MyProxyClientError('No client certificate and private ' 813 'key set and no $GLOBUS_LOCATION set ' 814 'in order to retrieve and use a host ' 815 'certificate and private key') 816 817 # Set up SSL connection 818 conn = self._initConnection(certFile=sslCertFile, 819 keyFile=sslKeyFile, 820 keyFilePassphrase=sslKeyFilePassphrase) 821 822 conn.connect((self.hostname, self.port)) 823 824 # send globus compatibility stuff 825 conn.write('0') 826 827 # send store command - ensure conversion from unicode before writing 828 cmd = MyProxyClient.PUT_CMD % (username, lifetime) 829 conn.write(str(cmd)) 830 831 # process server response 832 dat = conn.recv(MyProxyClient.SERVER_RESP_BLK_SIZE) 833 834 respCode, errorTxt = self._deserializeResponse(dat) 835 if respCode: 836 raise MyProxyClientGetError(errorTxt) 837 838 # Get the certificate request generated by the server 839 certReqDat = conn.recv(MyProxyClient.SERVER_RESP_BLK_SIZE) 840 certReq = crypto.load_certificate_request(crypto.FILETYPE_ASN1, 841 certReqDat) 842 pubKey = certReq.get_pubkey() 843 userKey = crypto.load_privatekey(crypto.FILETYPE_PEM, 844 open(userKeyFile).read(), 845 'testpassword') 846 847 userCert = crypto.load_certificate(crypto.FILETYPE_PEM, 848 open(userCertFile).read()) 849 850 # Create the proxy certificate 851 proxyCert = crypto.X509() 852 userCertSubject = userCert.get_subject() 853 proxyCert.set_issuer(userCertSubject) 854 proxyCert.set_pubkey(pubKey) 855 proxyCert.set_notBefore('20100421130000Z') 856 proxyCert.set_notAfter('20100421170000Z') 857 proxyCert.set_serial_number(12345) 858 proxyCertSubject = crypto.X509Name(userCertSubject) 859 proxyCertSubject.CN = userCertSubject.CN+'/CN=1234567' 860 861 proxyCert.set_subject(proxyCertSubject) 862 proxyCert.set_version(3) 863 864 # Oops not currently supported! 865 # extension = crypto.X509Extension('proxyCertInfo', 866 # 1, 867 # 'Path Length Constraint: infinite') 868 # proxyCert.add_extensions([extension]) 869 proxyCert.sign(userKey, 'md5') 870 wantRead = conn.want_read() 871 wantWrite = conn.want_write() 872 873 nCerts = '\002' 874 conn.send(nCerts) 875 conn.send(crypto.dump_certificate(crypto.FILETYPE_ASN1, proxyCert)) 876 conn.send(crypto.dump_certificate(crypto.FILETYPE_ASN1, userCert)) 877 878 resp = conn.recv(MyProxyClient.SERVER_RESP_BLK_SIZE) 879 respCode, errorTxt = self._deserializeResponse(resp) 880 if respCode: 881 raise MyProxyClientRetrieveError(errorTxt) 760 882 761 883 def info(self, 762 884 username, 763 ownerCertFile=None,764 ownerKeyFile=None,765 ownerPassphrase=None):885 sslCertFile=None, 886 sslKeyFile=None, 887 sslKeyFilePassphrase=None): 766 888 """return True/False whether credentials exist on the server for a 767 889 given username … … 772 894 @type username: string 773 895 @param username: username selected for credential 774 @type ownerCertFile: string775 @param ownerCertFile: certificate used for client authentication with896 @type sslCertFile: string 897 @param sslCertFile: certificate used for client authentication with 776 898 the MyProxy server SSL connection. This ID will be set as the owner 777 899 of the stored credentials. Only the owner can later remove 778 900 credentials with myproxy-destroy or the destroy method. If not set, 779 901 this argument defaults to $GLOBUS_LOCATION/etc/hostcert.pem 780 @type ownerKeyFile: string781 @param ownerKeyFile: corresponding private key file. See explanation782 for ownerCertFile783 @type ownerPassphrase: string784 @param ownerPassphrase: passphrase for ownerKeyFile. Omit if the902 @type sslKeyFile: string 903 @param sslKeyFile: corresponding private key file. See explanation 904 for sslCertFile 905 @type sslKeyFilePassphrase: string 906 @param sslKeyFilePassphrase: passphrase for sslKeyFile. Omit if the 785 907 private key is not password protected. 786 908 """ 787 909 globusLoc = os.environ.get('GLOBUS_LOCATION') 788 if not ownerCertFile:910 if not sslCertFile: 789 911 if globusLoc: 790 ownerCertFile = os.path.join(globusLoc,912 sslCertFile = os.path.join(globusLoc, 791 913 *MyProxyClient._hostCertSubDirPath) 792 ownerKeyFile = os.path.join(globusLoc,914 sslKeyFile = os.path.join(globusLoc, 793 915 *MyProxyClient._hostKeySubDirPath) 794 916 else: … … 797 919 798 920 # Set-up SSL connection 799 conn = self._initConnection( ownerCertFile=ownerCertFile,800 ownerKeyFile=ownerKeyFile,801 ownerPassphrase=ownerPassphrase)921 conn = self._initConnection(certFile=sslCertFile, 922 keyFile=sslKeyFile, 923 keyFilePassphrase=sslKeyFilePassphrase) 802 924 803 925 conn.connect((self.hostname, self.port)) … … 821 943 return not bool(respCode), errorTxt, field 822 944 823 824 945 def changePassphrase(self, 825 946 username, 826 947 passphrase, 827 948 newPassphrase, 828 ownerCertFile=None,829 ownerKeyFile=None,830 ownerPassphrase=None):949 sslCertFile=None, 950 sslKeyFile=None, 951 sslKeyFilePassphrase=None): 831 952 """change pass-phrase protecting the credentials for a given username 832 953 … … 837 958 @param passphrase: existing pass-phrase for credential 838 959 @param newPassphrase: new pass-phrase to replace the existing one. 839 @param ownerCertFile: certificate used for client authentication with960 @param sslCertFile: certificate used for client authentication with 840 961 the MyProxy server SSL connection. This ID will be set as the owner 841 962 of the stored credentials. Only the owner can later remove 842 963 credentials with myproxy-destroy or the destroy method. If not set, 843 964 this argument defaults to $GLOBUS_LOCATION/etc/hostcert.pem 844 @param ownerKeyFile: corresponding private key file. See explanation845 for ownerCertFile846 @param ownerPassphrase: passphrase for ownerKeyFile. Omit if the965 @param sslKeyFile: corresponding private key file. See explanation 966 for sslCertFile 967 @param sslKeyFilePassphrase: passphrase for sslKeyFile. Omit if the 847 968 private key is not password protected. 848 969 @return none 849 970 """ 850 971 globusLoc = os.environ.get('GLOBUS_LOCATION') 851 if not ownerCertFile or not ownerKeyFile:972 if not sslCertFile or not sslKeyFile: 852 973 if globusLoc: 853 ownerCertFile = os.path.join(globusLoc,974 sslCertFile = os.path.join(globusLoc, 854 975 *MyProxyClient._hostCertSubDirPath) 855 ownerKeyFile = os.path.join(globusLoc,976 sslKeyFile = os.path.join(globusLoc, 856 977 *MyProxyClient._hostKeySubDirPath) 857 978 else: … … 860 981 861 982 # Set-up SSL connection 862 conn = self._initConnection( ownerCertFile=ownerCertFile,863 ownerKeyFile=ownerKeyFile,864 ownerPassphrase=ownerPassphrase)983 conn = self._initConnection(certFile=sslCertFile, 984 keyFile=sslKeyFile, 985 keyFilePassphrase=sslKeyFilePassphrase) 865 986 866 987 conn.connect((self.hostname, self.port)) … … 882 1003 raise MyProxyClientGetError(errorTxt) 883 1004 884 885 1005 def destroy(self, 886 1006 username, 887 ownerCertFile=None,888 ownerKeyFile=None,889 ownerPassphrase=None):1007 sslCertFile=None, 1008 sslKeyFile=None, 1009 sslKeyFilePassphrase=None): 890 1010 """destroy credentials from the server for a given username 891 1011 … … 894 1014 895 1015 @param username: username selected for credential 896 @param ownerCertFile: certificate used for client authentication with1016 @param sslCertFile: certificate used for client authentication with 897 1017 the MyProxy server SSL connection. This ID will be set as the owner 898 1018 of the stored credentials. Only the owner can later remove 899 1019 credentials with myproxy-destroy or the destroy method. If not set, 900 1020 this argument defaults to $GLOBUS_LOCATION/etc/hostcert.pem 901 @param ownerKeyFile: corresponding private key file. See explanation902 for ownerCertFile903 @param ownerPassphrase: passphrase for ownerKeyFile. Omit if the1021 @param sslKeyFile: corresponding private key file. See explanation 1022 for sslCertFile 1023 @param sslKeyFilePassphrase: passphrase for sslKeyFile. Omit if the 904 1024 private key is not password protected. 905 1025 @return none 906 1026 """ 907 1027 globusLoc = os.environ.get('GLOBUS_LOCATION') 908 if not ownerCertFile or not ownerKeyFile:1028 if not sslCertFile or not sslKeyFile: 909 1029 if globusLoc: 910 ownerCertFile = os.path.join(globusLoc,1030 sslCertFile = os.path.join(globusLoc, 911 1031 *MyProxyClient._hostCertSubDirPath) 912 ownerKeyFile = os.path.join(globusLoc,1032 sslKeyFile = os.path.join(globusLoc, 913 1033 *MyProxyClient._hostKeySubDirPath) 914 1034 else: … … 917 1037 918 1038 # Set-up SSL connection 919 conn = self._initConnection( ownerCertFile=ownerCertFile,920 ownerKeyFile=ownerKeyFile,921 ownerPassphrase=ownerPassphrase)1039 conn = self._initConnection(certFile=sslCertFile, 1040 keyFile=sslKeyFile, 1041 keyFilePassphrase=sslKeyFilePassphrase) 922 1042 923 1043 conn.connect((self.hostname, self.port)) … … 936 1056 if respCode: 937 1057 raise MyProxyClientGetError(errorTxt) 938 939 1058 940 1059 def store(self, … … 943 1062 certFile, 944 1063 keyFile, 945 ownerCertFile=None,946 ownerKeyFile=None,947 ownerPassphrase=None,1064 sslCertFile=None, 1065 sslKeyFile=None, 1066 sslKeyFilePassphrase=None, 948 1067 lifetime=None, 949 1068 force=True): … … 962 1081 @type keyFile: string 963 1082 @param keyFile: equivalent private key file in PEM format 964 @type ownerCertFile: string965 @param ownerCertFile: certificate used for client authentication with1083 @type sslCertFile: string 1084 @param sslCertFile: certificate used for client authentication with 966 1085 the MyProxy server SSL connection. This ID will be set as the owner 967 1086 of the stored credentials. Only the owner can later remove … … 969 1088 this argument defaults to $GLOBUS_LOCATION/etc/hostcert.pem or if this 970 1089 is not set, certFile 971 @type ownerKeyFile: string972 @param ownerKeyFile: corresponding private key file. See explanation973 for ownerCertFile974 @type ownerPassphrase: string975 @param ownerPassphrase: passphrase for ownerKeyFile. Omit if the1090 @type sslKeyFile: string 1091 @param sslKeyFile: corresponding private key file. See explanation 1092 for sslCertFile 1093 @type sslKeyFilePassphrase: string 1094 @param sslKeyFilePassphrase: passphrase for sslKeyFile. Omit if the 976 1095 private key is not password protected. Nb. keyFile is expected to 977 1096 be passphrase protected as this will be the passphrase used for … … 993 1112 994 1113 globusLoc = os.environ.get('GLOBUS_LOCATION') 995 if not ownerCertFile or not ownerKeyFile:1114 if not sslCertFile or not sslKeyFile: 996 1115 if globusLoc: 997 ownerCertFile = os.path.join(globusLoc,1116 sslCertFile = os.path.join(globusLoc, 998 1117 *MyProxyClient._hostCertSubDirPath) 999 ownerKeyFile = os.path.join(globusLoc,1118 sslKeyFile = os.path.join(globusLoc, 1000 1119 *MyProxyClient._hostKeySubDirPath) 1001 1120 else: 1002 1121 # Default so that the owner is the same as the ID of the 1003 1122 # credentials to be uploaded. 1004 ownerCertFile = certFile1005 ownerKeyFile = keyFile1006 ownerPassphrase = passphrase1123 sslCertFile = certFile 1124 sslKeyFile = keyFile 1125 sslKeyFilePassphrase = passphrase 1007 1126 1008 1127 if not force: 1009 1128 # Check credentials don't already exist 1010 1129 if self.info(username, 1011 ownerCertFile=ownerCertFile,1012 ownerKeyFile=ownerKeyFile,1013 ownerPassphrase=ownerPassphrase)[0]:1130 sslCertFile=sslCertFile, 1131 sslKeyFile=sslKeyFile, 1132 sslKeyFilePassphrase=sslKeyFilePassphrase)[0]: 1014 1133 raise MyProxyCredentialsAlreadyExist( 1015 1134 "Credentials already exist for user: %s" % username) 1016 1135 1017 1136 # Set up SSL connection 1018 conn = self._initConnection( ownerCertFile=ownerCertFile,1019 ownerKeyFile=ownerKeyFile,1020 ownerPassphrase=ownerPassphrase)1137 conn = self._initConnection(certFile=sslCertFile, 1138 keyFile=sslKeyFile, 1139 keyFilePassphrase=sslKeyFilePassphrase) 1021 1140 1022 1141 conn.connect((self.hostname, self.port)) … … 1049 1168 raise MyProxyClientRetrieveError(errorTxt) 1050 1169 1051 1052 1170 def logon(self, username, passphrase, lifetime=None, keyPair=None, 1053 1171 certReq=None, nBitsForKey=PRIKEY_NBITS): -
TI12-security/trunk/MyProxyClient/myproxy/test/myProxyClient.cfg
r6829 r6840 23 23 #serverDN=/O=NDG/OU=Raphael/CN=raphael 24 24 25 # Set "host/" prefix to host cert CN as is default with globus26 serverCNPrefix=host/27 28 25 # This directory path is used to locate the OpenSSL configuration file 29 26 # -
TI12-security/trunk/MyProxyClient/myproxy/test/myProxyClientTest.cfg
r6829 r6840 18 18 username: testuser 19 19 passphrase: testpassword 20 signingCertFilePath: $MYPROXYCLIENT_UNITTEST_DIR/testuser.crt 21 signingPriKeyFilePath: $MYPROXYCLIENT_UNITTEST_DIR/testuser.key 22 ownerCertFile: $MYPROXYCLIENT_UNITTEST_DIR/testuser.crt 23 ownerKeyFile: $MYPROXYCLIENT_UNITTEST_DIR/testuser.key 24 ownerPassphrase: testpassword 20 sslCertFile: $MYPROXYCLIENT_UNITTEST_DIR/testuser.crt 21 sslKeyFile: $MYPROXYCLIENT_UNITTEST_DIR/testuser.key 22 sslKeyFilePassphrase: testpassword 25 23 26 24 [test02GetDelegation] … … 33 31 [test03Info] 34 32 username: testuser 35 ownerCertFile: $MYPROXYCLIENT_UNITTEST_DIR/proxy.crt36 ownerKeyFile: $MYPROXYCLIENT_UNITTEST_DIR/proxy.key37 ownerPassphrase: testpassword33 sslCertFile: $MYPROXYCLIENT_UNITTEST_DIR/proxy.crt 34 sslKeyFile: $MYPROXYCLIENT_UNITTEST_DIR/proxy.key 35 sslKeyFilePassphrase: testpassword 38 36 39 37 [test04ChangePassphrase] 40 38 username: testuser 41 ownerCertFile: $MYPROXYCLIENT_UNITTEST_DIR/proxy.crt42 ownerKeyFile: $MYPROXYCLIENT_UNITTEST_DIR/proxy.key39 sslCertFile: $MYPROXYCLIENT_UNITTEST_DIR/proxy.crt 40 sslKeyFile: $MYPROXYCLIENT_UNITTEST_DIR/proxy.key 43 41 passphrase: testpassword 44 42 newPassphrase: testpassword2 45 ownerPassphrase: testpassword43 sslKeyFilePassphrase: testpassword 46 44 47 45 [test05Destroy] 48 46 username: testuser 49 ownerCertFile: $MYPROXYCLIENT_UNITTEST_DIR/proxy.crt 50 ownerKeyFile: $MYPROXYCLIENT_UNITTEST_DIR/proxy.key 51 ownerPassphrase: testpassword 47 sslCertFile: $MYPROXYCLIENT_UNITTEST_DIR/proxy.crt 48 sslKeyFile: $MYPROXYCLIENT_UNITTEST_DIR/proxy.key 49 sslKeyFilePassphrase: testpassword 50 51 [test07Put] 52 username: proxytestuser 53 passphrase: proxypassword 54 userCertFile: $MYPROXYCLIENT_UNITTEST_DIR/testuser.crt 55 userKeyFile: $MYPROXYCLIENT_UNITTEST_DIR/testuser.key 56 sslCertFile: $MYPROXYCLIENT_UNITTEST_DIR/testuser.crt 57 sslKeyFile: $MYPROXYCLIENT_UNITTEST_DIR/testuser.key 58 sslKeyFilePassphrase: testpassword -
TI12-security/trunk/MyProxyClient/myproxy/test/proxy.crt
r6837 r6840 1 1 -----BEGIN CERTIFICATE----- 2 MIICfTCCAeagAwIBAgIEeVU+zzANBgkqhkiG9w0BAQUFADAlMRAwDgYDVQQKEwdH 3 YWJyaWVsMREwDwYDVQQDEwh0ZXN0dXNlcjAeFw0xMDA0MjExNTMxMjVaFw0xMDA0 4 MjIwOTM2MjVaMDoxEDAOBgNVBAoTB0dhYnJpZWwxETAPBgNVBAMTCHRlc3R1c2Vy 5 MRMwEQYDVQQDEwoyMDM1NjI5Nzc1MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB 6 CgKCAQEA3xsYzad74OW10LnCPO+DRZDbhin7/L1E8XKdPKrmau0Gt1HrpEiXsAa4 7 WwhdCJZ/i/eDwRCNQDvcqQ6O4fBpyl3pk3LOjZOHsZir1ya8pODOjhfQI4hRY1Da 8 R7PIh2woa13qFj0lTlaeYMEtxcC6Mp1q/wdnAzIJtQgXlVlPfB4cnQBFp8q5+8RO 9 ZGe8ie2yHT9mo02ymoKwtWHUJbhLc7LFkV1D9/GdtmfrfyOd8oOleGM9p29omtA8 10 0qnnaj2oqr5XvEFu3ThxSC0Y3QI16QKJCdK+0PyEtj5NZ3OqtYK+GnkgLftKfjUL 11 1c078kBWkcwS042lIMhmgAjM0hD7ZwIDAQABoyEwHzAdBggrBgEFBQcBDgEB/wQO 12 MAwwCgYIKwYBBQUHFQEwDQYJKoZIhvcNAQEFBQADgYEAlyn+pgDT0AuKZpBRdLLN 13 lbNBVlVrOz1tBvBpyuuzhuS8GpAO7AJb8FuvyWNqXPSjSXzzm6CDFX0pXKuaA0VM 14 QZ/gG61o1ky2xhbJfgMxousIyu32YlPfUrmv5xM7pgl3NCuK67fJMC13hjq+RkT1 15 wDMNhY1ngTo1sxV8UnKjcx0= 2 MIIDfTCCAuagAwIBAgI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zYHtwRI86UrpuBZydPhaPFH2LFWHWW3mmBLnoWH2dhTLdPpsfn6W4G 19 /iCZZGf09zR/VgVZvqAuLZagMTY4hn2GGjbOgfF/+pt+4GUGBoJMyX0tG/ksh3T5 20 +009F3GkkP/9WwGjM7QCIoaaJbCsT41iw8h+dPwHHNdi 16 21 -----END CERTIFICATE----- 17 22 -----BEGIN CERTIFICATE----- -
TI12-security/trunk/MyProxyClient/myproxy/test/proxy.key
r6837 r6840 1 1 -----BEGIN RSA PRIVATE KEY----- 2 MIIEpQIBAAKCAQEA3xsYzad74OW10LnCPO+DRZDbhin7/L1E8XKdPKrmau0Gt1Hr 3 pEiXsAa4WwhdCJZ/i/eDwRCNQDvcqQ6O4fBpyl3pk3LOjZOHsZir1ya8pODOjhfQ 4 I4hRY1DaR7PIh2woa13qFj0lTlaeYMEtxcC6Mp1q/wdnAzIJtQgXlVlPfB4cnQBF 5 p8q5+8ROZGe8ie2yHT9mo02ymoKwtWHUJbhLc7LFkV1D9/GdtmfrfyOd8oOleGM9 6 p29omtA80qnnaj2oqr5XvEFu3ThxSC0Y3QI16QKJCdK+0PyEtj5NZ3OqtYK+Gnkg 7 LftKfjUL1c078kBWkcwS042lIMhmgAjM0hD7ZwIDAQABAoIBAQDMuCiCTPS24RF8 8 fXdmQsDJzKoi6dN3jpT8mJb/XDIiW2yWOm1nSdUmiIQRxBLaFn7jCDO1rGJwVn2c 9 AufJGrl4H8R8sBQohP82T0kfG0RuZnoimGc8s5E6+K3SrX2MBgrwujRaQ7E/uOuL 10 DLfbhYVVfGz5puk3XWra2poJSPJOh/vigFF9mrKUSMNHr9wfRr9nPCMBLv7MUkwW 11 OsrFCEQpm75myJT82mWiGaKrSz8y4rvrPq2XhalnJ0DeeXFB3wU+h90McG3tL1PT 12 2cKoPfU9yYtTBgxJHwFnrjS87jg8RgExm9PX03VPzErXjHbTpl3z9PGU2asNhCOv 13 +Qjsj/jBAoGBAPnhuzgJqnYEWDzs6D3QM3EorD4I2lhi+6c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 5TSUOAdy79Qg6+ByxUDMrVZM/BN26JOH+CAXaHRVk0xc0IiXjAd0GbhrBaZuu1Ot 38 ouLlpb2bcWSLYO2j034n68aCgeVdGlr0yN5Ieq9NHldn5a2NA5P5Nxs+bVPDvnZk 39 JLZwfz9LXaRwJOFSqBI8BB/oiIpXGSYxXTdMMD/N26dOiNhfsakA38UZ2gK2EDfY 40 aRQFAoIBAHxu4Anoix10DmNXjPl258ABKkADmusVIf8dUiZlfoPsA8Q7gB7hqErn 41 935aGylK57q7fQKcqG7/m+ExEJJJh2GXKUg9t4V0aPXARBAJp4waNCjTr8QOFBUp 42 ToQUAMObpu7OzXHM2eXQTRdYCOG4M8Yg0zoF/p2CXB9AdzEeUt6a1L9tLwLn57m3 43 XT15QCDfjIyTJUUvudNv2yz01QjUvpILwys8ARDW7boS+VZAgZercOzvikp/swkp 44 kzNoMKGtxrZyfiGe8HCwVDKuCI8Ayf+rVgNF4zP8jr9fl1hh43qcXX/X+GUujgdz 45 akVnRqUbshBL6gdXi76ET7+JYh5OGpkCggEACVn9R8R9HU1NCX/Vu+wSmA5QWQ3g 46 Jego0/GFYStzaxOE9GjgJF/Mmpdgv/q0xG7YXMVSgQ+2vjpFvfiFeonCBZngS7rS 47 S3R5NRWbbMVg0UOBviML8j+tpIWV0mvb/fLtpjfn5kdGuG+zxDYuxYJliha0Jsm2 48 3M+pkdTkraHjIzjVriH+yi90iTkLc93QQgVDD6ol7lV2n5XEfqoM6sTkUaQyNusD 49 iX4wBp02Xxda70nW15G+KPmibl/7IJdNP07BMbdO+tGSYug3R0iX+GOVsnozF6CV 50 8W91hTP2E/UI4eB20vgJPnAt0n4GmSTX8IGhM5sAhPBEanttf6o5luXH0Q== 27 51 -----END RSA PRIVATE KEY----- -
TI12-security/trunk/MyProxyClient/myproxy/test/test_myproxyclient.py
r6837 r6840 67 67 "pass-phrase: ") 68 68 69 ownerPassphrase = thisSection.get('ownerPassphrase')70 if ownerPassphrase is None:71 ownerPassphrase = getpass.getpass(prompt="\ntest1Store credential "69 sslKeyFilePassphrase = thisSection.get('sslKeyFilePassphrase') 70 if sslKeyFilePassphrase is None: 71 sslKeyFilePassphrase = getpass.getpass(prompt="\ntest1Store credential " 72 72 " owner pass-phrase: ") 73 73 74 74 certFile = path.expandvars(thisSection['signingCertFilePath']) 75 75 keyFile = path.expandvars(thisSection['signingPriKeyFilePath']) 76 ownerCertFile = path.expandvars(thisSection['ownerCertFile'])77 ownerKeyFile = path.expandvars(thisSection['ownerKeyFile'])76 sslCertFile = path.expandvars(thisSection['sslCertFile']) 77 sslKeyFile = path.expandvars(thisSection['sslKeyFile']) 78 78 79 79 self.clnt.store(thisSection['username'], … … 81 81 certFile, 82 82 keyFile, 83 ownerCertFile=ownerCertFile,84 ownerKeyFile=ownerKeyFile,85 ownerPassphrase=ownerPassphrase,83 sslCertFile=sslCertFile, 84 sslKeyFile=sslKeyFile, 85 sslKeyFilePassphrase=sslKeyFilePassphrase, 86 86 force=False) 87 87 print("Store creds for user %s" % thisSection['username']) … … 109 109 thisSection = self.cfg['test03Info'] 110 110 111 # ownerPassphrase can be omitted from the congif file in which case111 # sslKeyFilePassphrase can be omitted from the congif file in which case 112 112 # the get call below would return None 113 ownerPassphrase = thisSection.get('ownerPassphrase')114 if ownerPassphrase is None:115 ownerPassphrase = getpass.getpass(prompt="\ntest3Info owner "113 sslKeyFilePassphrase = thisSection.get('sslKeyFilePassphrase') 114 if sslKeyFilePassphrase is None: 115 sslKeyFilePassphrase = getpass.getpass(prompt="\ntest3Info owner " 116 116 "credentials passphrase: ") 117 117 118 118 credExists, errorTxt, fields = self.clnt.info( 119 119 thisSection['username'], 120 path.expandvars(thisSection[' ownerCertFile']),121 path.expandvars(thisSection[' ownerKeyFile']),122 ownerPassphrase=ownerPassphrase)120 path.expandvars(thisSection['sslCertFile']), 121 path.expandvars(thisSection['sslKeyFile']), 122 sslKeyFilePassphrase=sslKeyFilePassphrase) 123 123 print "test3Info... " 124 124 print "credExists: %s" % credExists … … 148 148 self.fail("New and confirmed new password don't match") 149 149 150 ownerPassphrase = thisSection.get('ownerPassphrase') or passphrase150 sslKeyFilePassphrase = thisSection.get('sslKeyFilePassphrase') or passphrase 151 151 152 152 self.clnt.changePassphrase(thisSection['username'], 153 153 passphrase, 154 154 newPassphrase, 155 path.expandvars(thisSection[' ownerCertFile']),156 path.expandvars(thisSection[' ownerKeyFile']),157 ownerPassphrase=ownerPassphrase)155 path.expandvars(thisSection['sslCertFile']), 156 path.expandvars(thisSection['sslKeyFile']), 157 sslKeyFilePassphrase=sslKeyFilePassphrase) 158 158 print("Changed pass-phrase") 159 159 … … 162 162 thisSection = self.cfg['test05Destroy'] 163 163 164 ownerPassphrase = thisSection.get('ownerPassphrase')165 if ownerPassphrase is None:166 ownerPassphrase = getpass.getpass(prompt="\ntest5Destroy "164 sslKeyFilePassphrase = thisSection.get('sslKeyFilePassphrase') 165 if sslKeyFilePassphrase is None: 166 sslKeyFilePassphrase = getpass.getpass(prompt="\ntest5Destroy " 167 167 "credential owner passphrase: ") 168 168 169 169 self.clnt.destroy(thisSection['username'], 170 ownerCertFile=path.expandvars(thisSection['ownerCertFile']),171 ownerKeyFile=path.expandvars(thisSection['ownerKeyFile']),172 ownerPassphrase=ownerPassphrase)170 sslCertFile=path.expandvars(thisSection['sslCertFile']), 171 sslKeyFile=path.expandvars(thisSection['sslKeyFile']), 172 sslKeyFilePassphrase=sslKeyFilePassphrase) 173 173 print("Destroy creds for user %s" % thisSection['username']) 174 174 … … 189 189 self.assert_(subj) 190 190 print("Trust root certificate retrieved with DN=%s" % subj) 191 191 192 def test07Put(self): 193 # Make a new credential on the server and a proxy certificate to it 194 thisSection = self.cfg['test07Put'] 195 196 response = self.clnt.put( 197 thisSection['username'], 198 thisSection['passphrase'], 199 path.expandvars(thisSection['userCertFile']), 200 path.expandvars(thisSection['userKeyFile']), 201 sslCertFile=path.expandvars(thisSection['sslCertFile']), 202 sslKeyFile=path.expandvars(thisSection['sslKeyFile']), 203 sslKeyFilePassphrase=thisSection['sslKeyFilePassphrase']) 204 192 205 193 206 from myproxy.utils.openssl import OpenSSLConfigError … … 204 217 os.environ['MYPROXY_SERVER_DN'] = '/O=NDG/OU=Raphael/CN=raphael' 205 218 os.environ['MYPROXY_SERVER_PORT'] = '20000' 206 client = MyProxyClient(serverCNPrefix='', 207 openSSLConfFilePath=mkPath('openssl.conf'), 219 client = MyProxyClient(openSSLConfFilePath=mkPath('openssl.conf'), 208 220 proxyCertMaxLifetime=60000, 209 221 proxyCertLifetime=30000, … … 218 230 self.assert_(client.caCertFilePath == mkPath('ndg-test-ca.crt')) 219 231 finally: 220 os.environ = environBackup 221 232 os.environ = environBackup 222 233 223 234 def test02SetProperties(self): … … 256 267 self.assert_( 257 268 client.caCertDir == mkPath('/etc/grid-security/certificates')) 269 258 270 259 271 if __name__ == "__main__": -
TI12-security/trunk/MyProxyClient/myproxy/utils/__init__.py
r6069 r6840 2 2 config files. 3 3 4 NERC Data 4 NERC DataGrid Project 5 5 """ 6 6 __author__ = "P J Kershaw" … … 10 10 __contact__ = "Philip.Kershaw@stfc.ac.uk" 11 11 __revision__ = '$Id: $' 12 from ConfigParser import SafeConfigParser 13 14 15 class CaseSensitiveConfigParser(SafeConfigParser): 16 '''Subclass the SafeConfigParser - to preserve the original string case of 17 config section names 18 ''' 19 def optionxform(self, optionstr): 20 '''Extend SafeConfigParser.optionxform to preserve case of option names 21 ''' 22 return optionstr
Note: See TracChangeset
for help on using the changeset viewer.