def METHOD_NAME(self, force=False):
    need_key = False
    need_cert = False
    if force:
        need_key = True
    else:
        with OnlPkiContextReadOnly(self.logger):
            if not os.path.exists(self.kpath):
                need_key = True
    if need_key:
        self.logger.info("Generating private key...")
        cmd = ('openssl', 'genrsa',
               '-out', self.kpath,
               str(sysconfig.pki.key.len),)
        with OnlPkiContextReadWrite(self.logger):
            if not os.path.isdir(self.CONFIG_PKI_DIR):
                os.makedirs(self.CONFIG_PKI_DIR)
            self._execute(cmd, logLevel=logging.INFO)
        need_cert = True
    else:
        self.logger.info("Using existing private key.")
    if need_cert:
        self.init_cert(force=True)