當前位置: 首頁>>代碼示例>>Python>>正文


Python ServerConf.getCaConfigFile方法代碼示例

本文整理匯總了Python中cpc.util.conf.server_conf.ServerConf.getCaConfigFile方法的典型用法代碼示例。如果您正苦於以下問題:Python ServerConf.getCaConfigFile方法的具體用法?Python ServerConf.getCaConfigFile怎麽用?Python ServerConf.getCaConfigFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cpc.util.conf.server_conf.ServerConf的用法示例。


在下文中一共展示了ServerConf.getCaConfigFile方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: OpenSSL

# 需要導入模塊: from cpc.util.conf.server_conf import ServerConf [as 別名]
# 或者: from cpc.util.conf.server_conf.ServerConf import getCaConfigFile [as 別名]

#.........這裏部分代碼省略.........
            f = open(self.conf.getCAIndexFile(), 'w')
            f.close()

        self._generateCaConf()


    def _generateCaChainFile(self):
        file = open(self.conf.getCaChainFile(), "w")
        shutil.copyfile(self.conf.getCACertFile(), self.conf.getCaChainFile())

    def _generateCert(self, privateKeyFile, certFile, certReqConfigFile):
        '''
        generates and cert request based on the provided private key
        writes a cert to the provided certFile path
        @input String privateKeyFile: path to the private key
        @Input String certFile: path to the cert file
        @Input String certReqConfigFile: path to the certificate configuration file
        '''

        args = ["openssl", "req", "-outform", "PEM", "-new", "-key", \
                privateKeyFile,
                "-config", certReqConfigFile,
                "-out", self.conf.getCertRequestFile()]
        p = subprocess.Popen(args, stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)

        (stdout, stderr) = p.communicate()
        if p.returncode == 1:
            raise SetupError(
                "An error occured while generating a certificate request\n openssl returned the following error:\n" % stderr)

        args = ["openssl", "ca", "-in",
                self.conf.getCertRequestFile(), "-config",
                self.conf.getCaConfigFile(), "-keyfile", \
                self.conf.getCAPrivateKey(),
                "-out", certFile]

        p = subprocess.Popen(args, stdin=subprocess.PIPE,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)

        (stdout, stderr) = p.communicate("y\ny\n")
        if p.returncode == 1:
            raise SetupError(
                "An error occured while generating a certificate request\n openssl returned the following error:\n" % stderr)


            #cleanup
        os.remove(self.conf.getCertRequestFile())

        #CONVERT TO PEM FORMAT
        args = ["openssl", "x509",
                "-in", certFile,
                "-out", certFile,
                "-outform", "PEM"]
        subprocess.call(args)

    def _generateRootCert(self):
        '''
        generates a root certificate. This is required to sign new certificates
        '''

        args = ["openssl", "req", "-outform", "PEM", "-config", \
                self.conf.getCaConfigFile(), "-new", "-key", \
                self.conf.getCAPrivateKey(), "-out", \
                self.conf.getCertRequestFile()]
開發者ID:abhirathb,項目名稱:copernicus,代碼行數:70,代碼來源:openssl.py


注:本文中的cpc.util.conf.server_conf.ServerConf.getCaConfigFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。