MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / CreateSSL

Function CreateSSL

tools.py:373–405  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

371
372# 自签证书
373def CreateSSL():
374 import base64
375 userInfo = public.get_user_info()
376 if not userInfo:
377 userInfo['uid'] = 0
378 userInfo['access_key'] = 'B' * 32
379 domains = get_host_all()
380 pdata = {
381 "action": "get_domain_cert",
382 "company": "宝塔面板",
383 "domain": ','.join(domains),
384 "uid": userInfo['uid'],
385 "access_key": userInfo['access_key'],
386 "panel": 1
387 }
388 cert_api = 'https://api.bt.cn/bt_cert'
389 res = public.httpPost(cert_api, {'data': json.dumps(pdata)})
390 try:
391 result = json.loads(res)
392 if 'status' in result:
393 if result['status']:
394 public.writeFile('ssl/certificate.pem', result['cert'])
395 public.writeFile('ssl/privateKey.pem', result['key'])
396 public.writeFile('ssl/baota_root.pfx', base64.b64decode(result['pfx']), 'wb+')
397 public.writeFile('ssl/root_password.pl', result['password'])
398 public.writeFile('data/ssl.pl', 'True')
399 public.ExecShell("/etc/init.d/bt reload")
400 print('1')
401 return True
402 except:
403 print('error:{}'.format(res))
404 print('0')
405 return False
406
407
408# 创建文件

Callers 3

set_panel_sslFunction · 0.70
create_reverse_proxyFunction · 0.70
tools.pyFile · 0.70

Calls 8

writeFileMethod · 0.80
ExecShellMethod · 0.80
get_host_allFunction · 0.70
get_user_infoMethod · 0.45
joinMethod · 0.45
dumpsMethod · 0.45
loadsMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected