Remove duplicate references to external CA type

Part of: https://pagure.io/freeipa/issue/6858

Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
This commit is contained in:
Fraser Tweedale 2017-05-18 10:18:20 +10:00 committed by Pavel Vomacka
parent c5afee964e
commit 1699cff350
4 changed files with 13 additions and 11 deletions

View File

@ -64,7 +64,7 @@ def parse_options():
default=False, help="unattended installation never prompts the user")
parser.add_option("--external-ca", dest="external_ca", action="store_true",
default=False, help="Generate a CSR to be signed by an external CA")
ext_cas = ("generic", "ms-cs")
ext_cas = tuple(x.value for x in cainstance.ExternalCAType)
parser.add_option("--external-ca-type", dest="external_ca_type",
type="choice", choices=ext_cas,
metavar="{{{0}}}".format(",".join(ext_cas)),

View File

@ -363,11 +363,6 @@ def uninstall():
ca_instance.uninstall()
class ExternalCAType(enum.Enum):
GENERIC = 'generic'
MS_CS = 'ms-cs'
class CASigningAlgorithm(enum.Enum):
SHA1_WITH_RSA = 'SHA1withRSA'
SHA_256_WITH_RSA = 'SHA256withRSA'
@ -413,7 +408,7 @@ class CAInstallInterface(dogtag.DogtagInstallInterface,
external_ca = master_install_only(external_ca)
external_ca_type = knob(
ExternalCAType, None,
cainstance.ExternalCAType, None,
description="Type of the external CA",
)
external_ca_type = master_install_only(external_ca_type)

View File

@ -25,6 +25,7 @@ import base64
import logging
import dbus
import enum
import ldap
import os
import pwd
@ -95,6 +96,11 @@ ADMIN_GROUPS = [
]
class ExternalCAType(enum.Enum):
GENERIC = 'generic'
MS_CS = 'ms-cs'
def check_port():
"""
Check that dogtag port (8443) is available.
@ -353,7 +359,7 @@ class CAInstance(DogtagInstance):
if ca_type is not None:
self.ca_type = ca_type
else:
self.ca_type = 'generic'
self.ca_type = ExternalCAType.GENERIC.value
self.no_db_setup = promote
self.use_ldaps = use_ldaps
@ -565,7 +571,7 @@ class CAInstance(DogtagInstance):
config.set("CA", "pki_external", "True")
config.set("CA", "pki_external_csr_path", self.csr_file)
if self.ca_type == 'ms-cs':
if self.ca_type == ExternalCAType.MS_CS.value:
# Include MS template name extension in the CSR
config.set("CA", "pki_req_ext_add", "True")
config.set("CA", "pki_req_ext_oid", "1.3.6.1.4.1.311.20.2")

View File

@ -60,7 +60,7 @@ class CACertManage(admintool.AdminTool):
"--self-signed", dest='self_signed',
action='store_true',
help="Sign the renewed certificate by itself")
ext_cas = ("generic", "ms-cs")
ext_cas = tuple(x.value for x in cainstance.ExternalCAType)
renew_group.add_option(
"--external-ca-type", dest="external_ca_type",
type="choice", choices=ext_cas,
@ -191,7 +191,8 @@ class CACertManage(admintool.AdminTool):
def renew_external_step_1(self, ca):
print("Exporting CA certificate signing request, please wait")
if self.options.external_ca_type == 'ms-cs':
if self.options.external_ca_type \
== cainstance.ExternalCAType.MS_CS.value:
profile = 'SubCA'
else:
profile = ''