Exemplo n.º 1
0
    def print_cdn_certificates_info(self, repos=False):
        keys = self._get_cdn_certificate_keys_and_certs()
        if not keys:
            log2(
                0,
                0,
                "No SSL certificates were found. Is your %s activated for CDN?"
                % PRODUCT_NAME,
                stream=sys.stderr)
            sys.exit(1)

        for key in keys:
            log(0, "======================================")
            log(0, "| Certificate/Key: %s" % key['description'])
            log(0, "======================================")
            if constants.CA_CERT_NAME == key[
                    'description'] or constants.CLIENT_CERT_PREFIX in key[
                        'description']:
                if not verify_certificate_dates(str(key['key'])):
                    log(0, "WARNING: This certificate is not valid.")
                cn, serial_number, not_before, not_after = get_certificate_info(
                    str(key['key']))
                log(0, "Common name:   %s" % str(cn))
                log(0, "Serial number: %s" % str(serial_number))
                log(0, "Valid from:    %s" % str(not_before))
                log(0, "Valid to:      %s" % str(not_after))
            if constants.CLIENT_CERT_PREFIX in key['description']:
                manager = CdnRepositoryManager(client_cert_id=int(key['id']))
                self.cdn_repository_manager = manager
                log(0, "Provided channels:")
                channel_tree, not_available_channels = self._tree_available_channels(
                )
                if not channel_tree:
                    log(0, "    NONE")
                for base_channel in sorted(channel_tree):
                    if base_channel not in not_available_channels:
                        log(0, "    * %s" % base_channel)
                    elif channel_tree[base_channel]:
                        log(
                            0, "    * %s (only child channels provided)" %
                            base_channel)
                    for child_channel in sorted(channel_tree[base_channel]):
                        log(0, "        * %s" % child_channel)
                if repos:
                    log(0, "Provided repositories:")
                    provided_repos = self.cdn_repository_manager.list_provided_repos(
                        key['id'])
                    for repo in sorted(provided_repos):
                        log(0, "    %s" % repo)
            log(0, "")
Exemplo n.º 2
0
    def print_cdn_certificates_info(self, repos=False):
        h = rhnSQL.prepare("""
            SELECT ck.id, ck.description, ck.key
            FROM rhnCryptoKeyType ckt,
                 rhnCryptoKey ck
            WHERE ckt.label = 'SSL'
              AND ckt.id = ck.crypto_key_type_id
              AND ck.description LIKE 'CDN_%'
              AND ck.org_id is NULL
            ORDER BY ck.description
        """)
        h.execute()
        keys = h.fetchall_dict() or []
        if not keys:
            log2(0, 0, "No SSL certificates were found. Is your %s activated for CDN?"
                 % PRODUCT_NAME, stream=sys.stderr)
            return

        for key in keys:
            log(0, "======================================")
            log(0, "| Certificate/Key: %s" % key['description'])
            log(0, "======================================")
            if constants.CA_CERT_NAME == key['description'] or constants.CLIENT_CERT_PREFIX in key['description']:
                if not verify_certificate_dates(str(key['key'])):
                    log(0, "WARNING: This certificate is not valid.")
                cn, serial_number, not_before, not_after = get_certificate_info(str(key['key']))
                log(0, "Common name:   %s" % str(cn))
                log(0, "Serial number: %s" % str(serial_number))
                log(0, "Valid from:    %s" % str(not_before))
                log(0, "Valid to:      %s" % str(not_after))
            if constants.CLIENT_CERT_PREFIX in key['description']:
                manager = CdnRepositoryManager(client_cert_id=int(key['id']))
                self.cdn_repository_manager = manager
                log(0, "Provided channels:")
                channel_tree, not_available_channels = self._tree_available_channels()
                if not channel_tree:
                    log(0, "    NONE")
                for base_channel in sorted(channel_tree):
                    if base_channel not in not_available_channels:
                        log(0, "    * %s" % base_channel)
                    elif channel_tree[base_channel]:
                        log(0, "    * %s (only child channels provided)" % base_channel)
                    for child_channel in sorted(channel_tree[base_channel]):
                        log(0, "        * %s" % child_channel)
                if repos:
                    log(0, "Provided repositories:")
                    provided_repos = self.cdn_repository_manager.list_provided_repos(key['id'])
                    for repo in sorted(provided_repos):
                        log(0, "    %s" % repo)
            log(0, "")
Exemplo n.º 3
0
    def print_cdn_certificates_info(self, repos=False):
        keys = self._get_cdn_certificate_keys_and_certs()
        if not keys:
            log2(0, 0, "No SSL certificates were found. Is your %s activated for CDN?"
                 % PRODUCT_NAME, stream=sys.stderr)
            sys.exit(1)

        for key in keys:
            log(0, "======================================")
            log(0, "| Certificate/Key: %s" % key['description'])
            log(0, "======================================")
            if constants.CA_CERT_NAME == key['description'] or constants.CLIENT_CERT_PREFIX in key['description']:
                if not verify_certificate_dates(str(key['key'])):
                    log(0, "WARNING: This certificate is not valid.")
                cn, serial_number, not_before, not_after = get_certificate_info(str(key['key']))
                log(0, "Common name:   %s" % str(cn))
                log(0, "Serial number: %s" % str(serial_number))
                log(0, "Valid from:    %s" % str(not_before))
                log(0, "Valid to:      %s" % str(not_after))
            if constants.CLIENT_CERT_PREFIX in key['description']:
                manager = CdnRepositoryManager(client_cert_id=int(key['id']))
                self.cdn_repository_manager = manager
                log(0, "Provided channels:")
                channel_tree, not_available_channels = self._tree_available_channels()
                if not channel_tree:
                    log(0, "    NONE")
                for base_channel in sorted(channel_tree):
                    if base_channel not in not_available_channels:
                        log(0, "    * %s" % base_channel)
                    elif channel_tree[base_channel]:
                        log(0, "    * %s (only child channels provided)" % base_channel)
                    for child_channel in sorted(channel_tree[base_channel]):
                        log(0, "        * %s" % child_channel)
                if repos:
                    log(0, "Provided repositories:")
                    provided_repos = self.cdn_repository_manager.list_provided_repos(key['id'])
                    for repo in sorted(provided_repos):
                        log(0, "    %s" % repo)
            log(0, "")
Exemplo n.º 4
0
    def print_cdn_certificates_info(self, repos=False):
        h = rhnSQL.prepare("""
            SELECT ck.id, ck.description, ck.key
            FROM rhnCryptoKeyType ckt,
                 rhnCryptoKey ck
            WHERE ckt.label = 'SSL'
              AND ckt.id = ck.crypto_key_type_id
              AND ck.description LIKE 'CDN_%'
              AND ck.org_id is NULL
            ORDER BY ck.description
        """)
        h.execute()
        keys = h.fetchall_dict() or []
        if not keys:
            log2(
                0,
                0,
                "No SSL certificates were found. Is your %s activated for CDN?"
                % PRODUCT_NAME,
                stream=sys.stderr)
            return

        for key in keys:
            log(0, "======================================")
            log(0, "| Certificate/Key: %s" % key['description'])
            log(0, "======================================")
            if constants.CA_CERT_NAME == key[
                    'description'] or constants.CLIENT_CERT_PREFIX in key[
                        'description']:
                if not verify_certificate_dates(str(key['key'])):
                    log(0, "WARNING: This certificate is not valid.")
                cn, serial_number, not_before, not_after = get_certificate_info(
                    str(key['key']))
                log(0, "Common name:   %s" % str(cn))
                log(0, "Serial number: %s" % str(serial_number))
                log(0, "Valid from:    %s" % str(not_before))
                log(0, "Valid to:      %s" % str(not_after))
            if constants.CLIENT_CERT_PREFIX in key['description']:
                manager = CdnRepositoryManager(client_cert_id=int(key['id']))
                self.cdn_repository_manager = manager
                log(0, "Provided channels:")
                channel_tree, not_available_channels = self._tree_available_channels(
                )
                if not channel_tree:
                    log(0, "    NONE")
                for base_channel in sorted(channel_tree):
                    if base_channel not in not_available_channels:
                        log(0, "    * %s" % base_channel)
                    elif channel_tree[base_channel]:
                        log(
                            0, "    * %s (only child channels provided)" %
                            base_channel)
                    for child_channel in sorted(channel_tree[base_channel]):
                        log(0, "        * %s" % child_channel)
                if repos:
                    log(0, "Provided repositories:")
                    provided_repos = self.cdn_repository_manager.list_provided_repos(
                        key['id'])
                    for repo in sorted(provided_repos):
                        log(0, "    %s" % repo)
            log(0, "")