Пример #1
0
    def Args(parser):
        id_group = parser.add_group(mutex=True,
                                    required=True,
                                    help='The certificate identifier.')
        base.Argument(
            '--serial-number',
            help='The serial number of the certificate.').AddToParser(id_group)
        concept_parsers.ConceptParser([
            presentation_specs.ResourcePresentationSpec(
                '--certificate',
                resource_args.CreateCertificateResourceSpec('certificate'),
                'The certificate to revoke.',
                flag_name_overrides={
                    'issuer': '',
                    'issuer-location': '',
                    'project': '',
                },
                group=id_group),
            presentation_specs.ResourcePresentationSpec(
                '--issuer',
                resource_args.CreateCertificateAuthorityResourceSpec(
                    'Issuing CA', 'issuer', 'issuer-location'),
                'The issuing certificate authority of the certificate to revoke.',
                required=False),
        ]).AddToParser(parser)

        flags.AddRevocationReasonFlag(parser)
Пример #2
0
    def Args(parser):
        id_group = parser.add_group(mutex=True,
                                    required=True,
                                    help='The certificate identifier.')
        serial_num_group = id_group.add_group(
            help='The serial number and certificate authority resource.',
            required=False)
        serial_num_group.add_argument(
            '--serial-number',
            help='The serial number of the certificate.',
            required=True)
        concept_parsers.ConceptParser([
            presentation_specs.ResourcePresentationSpec(
                '--certificate',
                resource_args.CreateCertificateResourceSpec('CERTIFICATE'),
                'The certificate to revoke.',
                required=False,
                prefixes=True,
                group=id_group),
            presentation_specs.ResourcePresentationSpec(
                '--issuer',
                resource_args.CreateCertificateAuthorityResourceSpec(
                    'CERTIFICATE_AUTHORITY', 'issuer', 'issuer-location'),
                'The issuing certificate authority of the certificate to revoke.',
                required=False,
                group=serial_num_group),
        ]).AddToParser(parser)

        flags.AddRevocationReasonFlag(parser)
Пример #3
0
    def Args(parser):
        base.Argument(
            '--cert-output-file',
            help=
            'The path where the resulting PEM-encoded certificate chain file should be written (ordered from leaf to root).',
            required=False).AddToParser(parser)
        flags.AddValidityFlag(parser, 'certificate', 'P30D', '30 days')
        labels_util.AddCreateLabelsFlags(parser)

        cert_generation_group = parser.add_group(
            mutex=True, required=True, help='Certificate generation method.')
        base.Argument(
            '--csr',
            help='A PEM-encoded certificate signing request file path.'
        ).AddToParser(cert_generation_group)

        # This group is not useful in the beta command, but is here for consistency
        # in the flag hierarchy with the GA command.
        non_csr_group = cert_generation_group.add_group(
            help=
            'Alternatively, you may describe the certificate and key to use.')
        key_group = non_csr_group.add_group(
            mutex=True,
            required=True,
            help=
            'To describe the key that will be used for this certificate, use '
            'one of the following options.')
        key_generation_group = key_group.add_group(
            help='To generate a new key pair, use the following:')
        base.Argument(
            '--generate-key',
            help=
            'Use this flag to have a new RSA-2048 private key securely generated on your machine.',
            action='store_const',
            const=True,
            default=False,
            required=True).AddToParser(key_generation_group)
        base.Argument('--key-output-file',
                      help=_KEY_OUTPUT_HELP,
                      required=True).AddToParser(key_generation_group)

        subject_group = non_csr_group.add_group(
            help='The subject names for the certificate.', required=True)
        flags.AddSubjectFlags(subject_group)
        reusable_config_group = non_csr_group.add_group(
            mutex=True,
            help='The x509 configuration used for this certificate.')
        flags.AddInlineReusableConfigFlags(reusable_config_group,
                                           is_ca_command=False,
                                           default_max_chain_length=0)

        cert_arg = 'CERTIFICATE'
        concept_parsers.ConceptParser([
            presentation_specs.ResourcePresentationSpec(
                cert_arg,
                resource_args.CreateCertificateResourceSpec(
                    cert_arg,
                    [CreateBeta._GenerateCertificateIdFallthrough()]),
                'The name of the certificate to issue. If the certificate ID is '
                'omitted, a random identifier will be generated according to the '
                'following format: {YYYYMMDD}-{3 random alphanumeric characters}-'
                '{3 random alphanumeric characters}. The certificate ID is not '
                'required when the issuing CA is in the DevOps tier.',
                required=True)
        ]).AddToParser(parser)

        concept_parsers.ConceptParser([
            presentation_specs.ResourcePresentationSpec(
                '--reusable-config',
                resource_args.
                CreateReusableConfigResourceSpec(location_fallthroughs=[
                    deps.Fallthrough(
                        function=lambda: '',
                        hint=(
                            'location will default to the same location as the '
                            'certificate'),
                        active=False,
                        plural=False)
                ]),
                'The Reusable Config containing X.509 values for this certificate.',
                flag_name_overrides={
                    'location': '',
                    'project': '',
                },
                group=reusable_config_group)
        ]).AddToParser(reusable_config_group)
Пример #4
0
    def Args(parser):
        base.Argument(
            '--cert-output-file',
            help=
            'The path where the resulting PEM-encoded certificate chain file should be written (ordered from leaf to root).',
            required=False).AddToParser(parser)
        flags.AddValidityFlag(parser, 'certificate', 'P30D', '30 days')
        labels_util.AddCreateLabelsFlags(parser)

        cert_generation_group = parser.add_group(
            mutex=True, required=True, help='Certificate generation method.')
        base.Argument(
            '--csr',
            help='A PEM-encoded certificate signing request file path.'
        ).AddToParser(cert_generation_group)

        key_generation_group = cert_generation_group.add_group(
            help='Alternatively, to generate a new key pair, use the following:'
        )
        base.Argument(
            '--generate-key',
            help=
            'Use this flag to have a new RSA-2048 private key securely generated on your machine.',
            action='store_const',
            const=True,
            default=False,
            required=True).AddToParser(key_generation_group)
        base.Argument('--key-output-file', help=KEY_OUTPUT_HELP,
                      required=True).AddToParser(key_generation_group)

        subject_group = key_generation_group.add_group(
            help='The subject names for the certificate.', required=True)
        flags.AddSubjectFlags(subject_group)
        reusable_config_group = key_generation_group.add_group(
            mutex=True,
            help='The x509 configuration used for this certificate.')
        flags.AddInlineReusableConfigFlags(reusable_config_group, is_ca=False)

        cert_arg = 'CERTIFICATE'
        id_fallthrough = deps.Fallthrough(
            function=certificate_utils.GenerateCertId,
            hint='certificate id will default to an automatically generated id',
            active=False,
            plural=False)
        concept_parsers.ConceptParser([
            presentation_specs.ResourcePresentationSpec(
                cert_arg,
                resource_args.CreateCertificateResourceSpec(
                    cert_arg, [id_fallthrough]),
                'The name of the certificate to issue. If the name is omitted, a '
                'random name will be generated according to the following format'
                ': {YYYYMMDD}-{3 random alphanumeric characters}-{3 random alph'
                'anumeric characters}.',
                required=True)
        ]).AddToParser(parser)

        concept_parsers.ConceptParser([
            presentation_specs.ResourcePresentationSpec(
                '--reusable-config',
                resource_args.CreateReusableConfigResourceSpec(
                    location_fallthrough=deps.Fallthrough(
                        function=lambda: '',
                        hint=(
                            'location will default to the same location as the '
                            'certificate'),
                        active=False,
                        plural=False)),
                'The Reusable Config containing X.509 values for this certificate.',
                flag_name_overrides={
                    'location': '',
                    'project': '',
                },
                group=reusable_config_group)
        ]).AddToParser(reusable_config_group)