|
|
|
@ -24,6 +24,7 @@ from calculate.api.datavars import DataVarsApi
|
|
|
|
|
|
|
|
|
|
from calculate.lib.utils import ip as ip_mod
|
|
|
|
|
import os, hashlib, time
|
|
|
|
|
from os import path
|
|
|
|
|
|
|
|
|
|
def init(cert, key, cert_path, data_path, certbase, args, port, user_name):
|
|
|
|
|
if check():
|
|
|
|
@ -52,13 +53,31 @@ def create_server_cert(cert, key, cert_path, args, port):
|
|
|
|
|
cert_cmd.check_server_certificate(cert, key, cert_path, args, port, auto = True)
|
|
|
|
|
|
|
|
|
|
def create_client_cert(server_cert, cert_path, data_path, certbase, user_name):
|
|
|
|
|
client_cert_path = '/home/' + user_name + '/.calculate/client_cert/'
|
|
|
|
|
client_cert_path = check_user_path(user_name)
|
|
|
|
|
if not client_cert_path:
|
|
|
|
|
print 'not client_cert_path'
|
|
|
|
|
return 1
|
|
|
|
|
req_id = create_request(server_cert, cert_path, data_path, certbase, \
|
|
|
|
|
client_cert_path)
|
|
|
|
|
sign_certificate(req_id, cert_path, data_path)
|
|
|
|
|
time.sleep(2)
|
|
|
|
|
get_certificate(cert_path, data_path, certbase, client_cert_path)
|
|
|
|
|
|
|
|
|
|
def check_user_path(user_name):
|
|
|
|
|
if user_name == 'root':
|
|
|
|
|
home_dir = '/root'
|
|
|
|
|
elif:
|
|
|
|
|
home_dir = '/home/' + user_name
|
|
|
|
|
if not path.isdir(home_dir):
|
|
|
|
|
pritn 'Not fount user %s' %user_name
|
|
|
|
|
return None
|
|
|
|
|
calc_dir = '/home/' + user_name + '/.calculate'
|
|
|
|
|
if not path.isdir(calc_dir):
|
|
|
|
|
os.makedirs(calc_dir)
|
|
|
|
|
client_cert_path = calc_dir + '/client_cert/'
|
|
|
|
|
if not path.isdir(client_cert_path):
|
|
|
|
|
os.makedirs(client_cert_path)
|
|
|
|
|
|
|
|
|
|
def create_request(server_cert, cert_path, data_path, certbase,client_cert_path):
|
|
|
|
|
server_host_name = 'localhost'
|
|
|
|
|
|
|
|
|
|