Forum Discussion

Patrik_Jonsson's avatar
Aug 02, 2022

Unable to update device cert

Hi! Working on a hobby project to manage F5 certificates using Kubernetes and cert-manager (Ref: https://community.f5.com/t5/technical-forum/kubernetes-cert-manager-letsencrypt-f5/td-p/299218). How...
  • Patrik_Jonsson's avatar
    Patrik_Jonsson
    Aug 07, 2022

    Final solution:

     

     

    def set_management_cert(self, cert_name, key_name):
    
        self.run_bash_command(f'restorecon -RvF /config/httpd/conf/ssl.crt/{cert_name}')
        self.run_bash_command(f'restorecon -RvF /config/httpd/conf/ssl.key/{key_name}')
    
        self.session.put(
            f'https://{self.device}/mgmt/tm/sys/httpd',
            json={
                'sslCertfile': '/config/httpd/conf/ssl.crt/management.crt',
                'sslCertkeyfile': '/config/httpd/conf/ssl.key/management.key'}
        )
        try:
            logger.info('Restarting httpd')
            self.run_bash_command('bigstart restart httpd; killall -9 httpd;bigstart restart httpd;')
        except:
            logger.info('Waiting for management interface to restart')
            time.sleep(3)
            httpd_config = self.get_httpd_config()
    
            if os.path.basename(httpd_config['sslCertfile']) == cert_name \
                    and os.path.basename(httpd_config['sslCertkeyfile']) == key_name:
                print('Certificate has been updated and the httpd interface is responding')
            else:
                raise Exception('Failed to update the certificate')

     

     

    Thank you for the suggestions and tips Dario_Garrido . Definitely helped me find the solution!