Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Migrate SSL certificates from WebFaction to Opalstack
import requests
from xmlrpc.client import ServerProxy
# your webfaction panel username
WF_USER = 'your_wf_username'
# your webfaction panel password
WF_PASS = 'your_wf_password'
# your webfaction server, if you are VPS it will be wf-NN-NN-NN-NN
WF_SERVER = 'webNNN'
# your opalstack API token from https://my.opalstack.com/tokens/
OPAL_TOKEN ='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
# do not edit below this line.
wf = ServerProxy('https://api.webfaction.com/')
wf_session, wf_account = wf.login(WF_USER,WF_PASS,WF_SERVER,2)
wfcerts =wf.list_certificates(wf_session)
OPAL_HEADERS = {
'Authorization': f'Token {OPAL_TOKEN}',
'Content-Type':'application/json'
}
for c in wfcerts:
payload = [{
'name': c['name'],
'cert': c['certificate'],
'intermediates': c['intermediates'],
'key': c['private_key']
}]
r = requests.post('https://my.opalstack.com/api/v1/cert/create/',
headers=OPAL_HEADERS,
json=payload
)
print(r.json())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment