Forum Discussion
romio28
Altostratus
Jan 12, 2023Export/Import ssl certificate from python f5-sdk
Hi, How to automate the export/import of ssl certificates from python sdk? Thanks in advance.
xuwen
Cumulonimbus
Jan 13, 2023Export the key and crt contents of the certificate in the system. There is no quick interface. The key and crt files are stored in:
/config/filestore/files_ d/Common_ d/certificate_ d/
/config/filestore/files_d/Common_d/certificate_key_d/
you can use the until.bash interface of the api to execute the cat command to view the corresponding file contents
Here is code to import local desk crt and key to F5:
from f5.bigip import ManagementRoot
mgmt = ManagementRoot('192.168.100.7', 'admin', 'xt3211@2020')
client_crt_name = 'gtm-client.crt'
client_key_name = 'gtm-client.key'
try:
mgmt.shared.file_transfer.uploads.upload_file(
filepathname=r'C:\Users\xuwen\Documents\{}'.format(client_crt_name),
target=client_crt_name)
except Exception as e:
print('import {} to F5 /var/config/rest/downloads/ failed, reason is '.format(client_crt_name) + str(e))
try:
mgmt.shared.file_transfer.uploads.upload_file(
filepathname=r'C:\Users\xuwen\Documents\{}'.format(client_key_name),
target=client_key_name)
except Exception as e:
print('import {} to F5 /var/config/rest/downloads/ failed, reason is '.format(client_key_name) + str(e))
else:
# create crt and key in GUI Web System ›› Certificate Management : Traffic Certificate Management : SSL Certificate List
if mgmt.tm.sys.file.ssl_certs.ssl_cert.exists(
name=client_crt_name,
partition='Common') is False:
try:
mgmt.tm.sys.file.ssl_certs.ssl_cert.create(
name=client_crt_name,
partition='Common',
sourcePath='file:/var/config/rest/downloads/{}'.format(
client_crt_name))
except Exception as e:
print('create crt in GUI Web System ›› Certificate Management : '
'Traffic Certificate Management : SSL Certificate Listt {} failed!'
' reason is: '.format(client_crt_name) + str(e))
try:
mgmt.tm.sys.file.ssl_keys.ssl_key.create(
name=client_key_name,
partition='Common',
sourcePath='file:/var/config/rest/downloads/{}'.format(
client_key_name))
except Exception as e:
print('create key in GUI Web System ›› Certificate Management {} failed! reason is:'
' '.format(client_key_name) + str(e))
- romio28Apr 05, 2023
Altostratus
It works as admin role but I cat upload files as Certificate Manager, it’s a big security issuefor us!
Any idea to solve the problem?thanks
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects