- 论坛徽章:
- 0
|
- [cbb@ iac tmp]$ python test.py
- Please input a password of ca.key: abcdefg
- Please input the Common name for ca.crt: uuuu
- [cbb@ iac tmp]$ ls
- ca.key create_crt.py CRX_75DAF8CB7768 fcitx-socket-:0 ssh-ONSNRvqG4uEM systemd-private-cYIrep test.py
- [cbb@ iac tmp]$ cat test.py
- #!/usr/bin/env pyhton
- # -*- condig:UTF-8 -*-
- import pexpect
- import os
- def create_ca():
- ca_passwd = raw_input('Please input a password of ca.key: ')
- domain = raw_input('Please input the Common name for ca.crt: ')
- child = pexpect.spawn('/usr/bin/openssl req -new -x509 -keyout ca.key -out ca.crt')
- child.expect('phrase')
- child.sendline('%s' % ca_passwd)
- child.expect('Verifying')
- child.sendline('%s' % ca_passwd)
- child.expect('Country Name')
- child.sendline('CN')
- child.expect('Province Name')
- child.sendline('Fujian')
- child.expect('Locality Name')
- child.sendline('XiaMen')
- child.expect('Organization Name')
- child.sendline('hy')
- child.expect('Unit Name')
- child.sendline('hy')
- child.expect('Common Name')
- child.sendline('%s' % domain)
- child.expect('Email Address')
- child.sendline('')
- create_ca()
- ------------------------------------
- [cbb@ iac tmp]$ /usr/bin/openssl req -new -x509 -keyout ca.key -out ca.crt
- Generating a 2048 bit RSA private key
- .....................................................................+++
- .....................+++
- writing new private key to 'ca.key'
- Enter PEM pass phrase:
- Verifying - Enter PEM pass phrase:
- -----
- You are about to be asked to enter information that will be incorporated
- into your certificate request.
- What you are about to enter is what is called a Distinguished Name or a DN.
- There are quite a few fields but you can leave some blank
- For some fields there will be a default value,
- If you enter '.', the field will be left blank.
- -----
- Country Name (2 letter code) [XX]:CN
- State or Province Name (full name) []:Fujian
- Locality Name (eg, city) [Default City]:XiaMen
- Organization Name (eg, company) [Default Company Ltd]:hy
- Organizational Unit Name (eg, section) []:hy
- Common Name (eg, your name or your server's hostname) []:uuuu
- Email Address []:
- [cbb@ iac tmp]$ ls
- ca.crt ca.key create_crt.py CRX_75DAF8CB7768 fcitx-socket-:0 ssh-ONSNRvqG4uEM systemd-private-cYIrep test.py
复制代码 用脚本无法生成ca.crt,只会生成ca.key
在shell用指令敲下就没有这个问题
为什么呐呐呐呐阿 |
|