(self, get)
| 1922 | |
| 1923 | # 获取面板证书 |
| 1924 | def GetPanelSSL(self, get): |
| 1925 | cert = {} |
| 1926 | key_file = 'ssl/privateKey.pem' |
| 1927 | cert_file = 'ssl/certificate.pem' |
| 1928 | if not os.path.exists(key_file): |
| 1929 | self.CreateSSL() |
| 1930 | cert['privateKey'] = public.readFile(key_file) |
| 1931 | cert['certPem'] = public.readFile(cert_file) |
| 1932 | cert['download_root'] = False |
| 1933 | cert['info'] = {} |
| 1934 | if not cert['privateKey']: |
| 1935 | cert['privateKey'] = '' |
| 1936 | cert['certPem'] = '' |
| 1937 | else: |
| 1938 | cert['info'] = public.get_cert_data(cert_file) |
| 1939 | if not cert['info']: |
| 1940 | self.CreateSSL() |
| 1941 | cert['info'] = public.get_cert_data(cert_file) |
| 1942 | if cert['info']: |
| 1943 | if cert['info']['issuer'] == '宝塔面板': |
| 1944 | if os.path.exists('ssl/baota_root.pfx'): |
| 1945 | cert['download_root'] = True |
| 1946 | cert['root_password'] = public.readFile('ssl/root_password.pl') |
| 1947 | ssl_path = "/www/server/panel/ssl/" |
| 1948 | if os.path.exists(ssl_path + 'baota_root.pfx') and not os.path.exists(ssl_path + 'baota_root.crt'): |
| 1949 | passwd = '' |
| 1950 | if os.path.exists('{}/root_password.pl'.format(ssl_path)): |
| 1951 | pwd = public.readFile('{}/root_password.pl'.format(ssl_path)) |
| 1952 | if pwd.strip(): |
| 1953 | passwd = "-passin file:{ssl_path}root_password.pl".format(ssl_path=ssl_path) |
| 1954 | shell = 'openssl pkcs12 -legacy -in {ssl_path}/baota_root.pfx -clcerts -nokeys -out {ssl_path}/baota_root.crt {passwd}'.format(ssl_path=ssl_path,passwd=passwd) |
| 1955 | public.print_log(public.ExecShell(shell)) |
| 1956 | cert['rep'] = os.path.exists('ssl/input.pl') |
| 1957 | from panelModel.panel_reverse_generationModel import main as panelNginxPrxoyMain |
| 1958 | cert['proxy_status'] = bool(panelNginxPrxoyMain().proxy_site()) |
| 1959 | return cert |
| 1960 | |
| 1961 | # 保存面板证书 |
| 1962 | def SavePanelSSL(self, get): |
no test coverage detected