cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Who rated this post

L0 Member

Hello Community i was able to create an SSL Profile using the api 

 

def create_ssl_profile(base_url,api_key):
FW_Name = hostname[hostname.find('fw'):hostname.find('.transit')]
Profile_Name = '{}-mgmt-ssl-tls-service-profile'.format(FW_Name)
#Create a session
session = requests.session()
params = {
'key': api_key,
'type': 'config',
'action': 'set',
'xpath': "/config/shared/ssl-tls-service-profile/entry[@name='profile_name']",
'element': "<certificate>New Wildcard Cert</certificate><protocol-settings><max-version>max</max-version><min-version>tls1-2</min-version></protocol-settings>"
}
old_string = 'profile_name'
new_string = Profile_Name
modified_xpath = params['xpath'].replace(old_string, new_string)
params['xpath'] = modified_xpath
try:
# Send a set request
response = session.post(base_url, params=params, verify=False)
response.raise_for_status()
except requests.exceptions.RequestException as e:
logging("An error occurred: {e}")
print("An error occurred: {e}")
sys.exit()
print('SSL Profile Created:', Profile_Name)
return Profile_Name

def Configure_SSL_Profile(base_url,api_key,Profile_Name):
#Create a session
session = requests.session()
params = {
'key': api_key,
'type': 'config',
'action': 'set',
'xpath': "/config/devices/entry[@name='localhost.localdomain']/deviceconfig/system",
'element': "<ssl-tls-service-profile>profile_name</ssl-tls-service-profile>"
}
old_string = 'profile_name'
new_string = Profile_Name
modified_xpath = params['element'].replace(old_string, new_string)
params['element'] = modified_xpath
try:
# Send a set request
response = session.post(base_url, params=params, verify=False)
response.raise_for_status()
except requests.exceptions.RequestException as e:
logging("An error occurred: {e}")
print("An error occurred: {e}")
sys.exit()
print('SSL Assingned to Interface:', Profile_Name)

def commit(base_url,api_key):
session = requests.session()
params = {
'key': api_key,
'type': 'commit',
'cmd': "<commit></commit>"
}
try:
# Send a commit request
response = session.get(base_url, params=params, verify=False)
response.raise_for_status()
except requests.exceptions.RequestException as e:
logging("An error occurred: {e}")
print("An error occurred: {e}")
sys.exit()
print('Commit Completed')
Who rated this post