nova-cert顾名思义,是与证书有关的服务,用于为上传镜像生成X509证书,只在EC2 API中才会被用到。
nova-cert作为rpc server运行,对外提供证书有关的RpcAPI,作用和CA类似。
由于对PKI了解的不是太多,因此下面可能有错漏,还望斧正
1.在服务开始运行之前,需要判断ca证书是否存在,不存在就需要使用openssl创建自己的ca证书和私钥,这些文件通常存放在配置项state_path下的CA目录里
def ensure_ca_filesystem():
# 确认CA目录的路径, 即配置项$state_path/CA
ca_dir = ca_folder()
# 如果CA证书不存在
if not os.path.exists(ca_path()):
# 确认genrootca.sh脚本的所在
genrootca_sh_path = os.path.abspath(
os.path.join(os.path.dirname(__file__), 'CA', 'genrootca.sh'))
start = os.getcwd()
# 创建CA目录
fileutils.ensure_tree(ca_dir)
# 切换工作目录至CA目录
os.chdir(ca_dir)
# 通过sh执行genrootca.sh脚本来生成CA证书和私钥
utils.execute("sh", genrootca_sh_path)
# 恢复原来的工作目录
os.chdir(st