Module clientcert
[hide private]
[frames] | no frames]

Source Code for Module clientcert

 1  # 
 2  # Copyright (c) 2014--2016 Red Hat, Inc. 
 3  # 
 4  # This software is licensed to you under the GNU General Public License, 
 5  # version 2 (GPLv2). There is NO WARRANTY for this software, express or 
 6  # implied, including the implied warranties of MERCHANTABILITY or FITNESS 
 7  # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 
 8  # along with this software; if not, see 
 9  # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 
10  # 
11  # Red Hat trademarks are not licensed under GPLv2. No permission is 
12  # granted to use or replicate Red Hat trademarks that are incorporated 
13  # in this software or its documentation. 
14   
15  import sys 
16   
17  if sys.version_info[0] == 3: 
18      unicode = str 
19   
20  from up2date_client import rhnreg 
21  from up2date_client import rhnserver 
22  from up2date_client import up2dateAuth 
23   
24  __rhnexport__ = [ 'update_client_cert' ] 
25   
26 -def update_client_cert(cache_only=None):
27 server = rhnserver.RhnServer() 28 29 if not server.capabilities.hasCapability('registration.update_systemid'): 30 return(1, 'parent lacks registration.update_systemid capability', {}) 31 32 old_system_id = up2dateAuth.getSystemId().strip() 33 new_system_id = server.registration.update_systemid(old_system_id).strip() 34 35 if old_system_id == new_system_id: 36 return (1, 'not updating client certificate: old and new certificates match', {}) 37 38 # Write out the new client certificate 39 if isinstance(new_system_id, unicode): 40 rhnreg.writeSystemId(unicode.encode(new_system_id, 'utf-8')) 41 else: 42 rhnreg.writeSystemId(new_system_id) 43 44 return (0, 'client certificate updated', {})
45