Beispiel #1
0
from gui.inputbox import inputbox
from gui.selector import selector
from gui.spinbox  import spinbox
import logging,sys,os,_util

BASEPATH = os.path.realpath(os.path.dirname(sys.argv[0]))

log = logging.getLogger('postoffice.tool.certnew')

# This will generate new certificate for user.

print "即将新建一个Xi证书。按Ctrl+C或Ctrl+D可以随时退出。"

c = certificate()

subj = inputbox('请输入新证书的题目:\n 1.只能由下列字符组成:a-z A-Z 空格 点(.)\n 2.长度3(含)到128(含)字符之间\n 3.开头结尾非空格')

if c._validate_subject(subj) == False:
    exit()

rsa_len = spinbox('选择RSA密钥长度:',['1024','2048','3072','4096','8192'])
if rsa_len == False:
    exit()

ec_type = selector('选择椭圆曲线类型:',_EC()._curves_id.keys())
if ec_type == False:
    exit()

level = inputbox("""
请输入您的证书的等级(1-100):
    证书的等级用在证书的签署中。只有高等级的证书才能签署
Beispiel #2
0
if len(privatelist) > 0:
    jobs.append(u'证书信任签署')
    jobs.append(u'证书吊销签署')
if len(publiclist) > 0:
    jobs.append(u'导入签署信息')

job = selector('选择任务:',jobs)

if job == False:
    exit()
else:
    jobid = jobs.index(job)


if jobid == 2: # 导入证书签名
    signtxt = inputbox('请将签名文本粘贴(Ctrl+V)到下面:','导入签名',True).decode('base64')
    try:
        signparsed = serializer.loads(signtxt)
        certified  = signparsed['Content']['Certified_ID']
        issued     = signparsed['Content']['Issuer_ID']
    except:
        log.warning('Given signature cannot be parsed. Data may corrupted.')
        print '证书格式不正确。'
        exit()
    # Find issuer(public) and holder(private), though issuer may not be verified yet.
    issuer, holder = None, None

    c = certificate()
    for u in publiclist:
        c_path = os.path.join(_util.BASEPATH,publiclist[u])
        c.load_public_text(open(c_path,'r').read())