def __remove_certificate(certificate_folder, logger):
    """
    Ensures that the certificates are created and registered. If something is amiss, then the
    configuration is fixed.

    :param certificate_folder: Folder where the certificates are stored.
    """

    cert_handler = get_certificate_handler(certificate_folder)

    # Removes the certificate from the OS/browser certificate database.
    if cert_handler.is_registered():
        logger.debug("Removing certificate from database.")
        __warn_for_prompt(removal=True)
        cert_handler.unregister()
        logger.info("The certificate is now unegistered.")
    else:
        logger.info("No certificate was registered.")

    # Removes the actual certificate files on disk.
    if cert_handler.exists():
        logger.debug("Certificate was found on disk at %s." % certificate_folder)
        cert_handler.remove_files()
        logger.info("The certificate was removed at %s." % certificate_folder)
    else:
        logger.info("No certificate was found on disk at %s." % certificate_folder)
def __remove_certificate(certificate_folder, logger):
    """
    Ensures that the certificates are created and registered. If something is amiss, then the
    configuration is fixed.

    :param certificate_folder: Folder where the certificates are stored.
    """

    cert_handler = get_certificate_handler(certificate_folder)

    # Removes the certificate from the OS/browser certificate database.
    if cert_handler.is_registered():
        logger.debug("Removing certificate from database.")
        __warn_for_prompt(removal=True)
        cert_handler.unregister()
        logger.info("The certificate is now unegistered.")
    else:
        logger.info("No certificate was registered.")

    # Removes the actual certificate files on disk.
    if cert_handler.exists():
        logger.debug("Certificate was found on disk at %s." % certificate_folder)
        cert_handler.remove_files()
        logger.info("The certificate was removed at %s." % certificate_folder)
    else:
        logger.info("No certificate was found on disk at %s." % certificate_folder)
def __ensure_certificate_ready(app_bootstrap, tk_framework_desktopserver, certificate_folder):
    """
    Ensures that the certificates are created and registered. If something is amiss, then the
    configuration is fixed.

    :params app_bootstrap: The application bootstrap.
    :param tk_framework_desktopserver: The desktopserver framework.
    :param certificate_folder: Folder where the certificates are stored.

    :returns: True is the certificate is ready, False otherwise.
    """
    cert_handler = tk_framework_desktopserver.get_certificate_handler(certificate_folder)

    # We only warn once.
    warned = False
    # Make sure the certificates exist.
    if not cert_handler.exists():
        logger.info("Certificate doesn't exist.")
        # Start by unregistering certificates from the keychains, this can happen if the user
        # wiped his shotgun/desktop/config/certificates folder.
        if cert_handler.is_registered():
            logger.info("Unregistering lingering certificate.")
            # Warn once.
            __warn_for_prompt()
            warned = True
            cert_handler.unregister()
            logger.info("Unregistered.")
        # Create the certificate files
        cert_handler.create()
        logger.info("Certificate created.")
    else:
        logger.info("Certificate already exist.")

    # Check if the certificates are registered with the keychain.
    if not cert_handler.is_registered():
        logger.info("Certificate not registered.")

        # Only if we've never been warned before.
        if not warned:
            __warn_for_prompt()
        cert_handler.register()
        logger.info("Certificate registered.")
    else:
        logger.info("Certificates already registered.")
    return True
示例#4
0
def __create_certificate(certificate_folder, logger):
    """
    Ensures that the certificates are created and registered. If something is amiss, then the
    configuration is fixed.

    :param certificate_folder: Folder where the certificates are stored.
    """

    cert_handler = get_certificate_handler(certificate_folder)

    # We only warn once.
    warned = False
    # Make sure the certificates exist.
    if not cert_handler.exists():
        logger.debug("Certificate doesn't exist on disk.")
        # Start by unregistering certificates from the keychains, this can happen if the user
        # wiped his certificates folder.
        if cert_handler.is_registered():
            # Warn once.
            __warn_for_prompt(removal=False)
            logger.debug("Unregistering dangling certificate from database...")
            warned = True
            cert_handler.unregister()
            logger.debug("Done.")
        # Create the certificate files
        logger.debug("About to create the certificates...")
        cert_handler.create()
        logger.info("Certificate created at %s." % certificate_folder)
    else:
        logger.info("Certificate already exist on disk at %s." %
                    certificate_folder)

    # Check if the certificates are registered with the keychain.
    if not cert_handler.is_registered():
        logger.debug(
            "Certificate is not currently registered in the keychain.")
        # Only if we've never been warned before.
        if not warned:
            __warn_for_prompt(removal=False)
        cert_handler.register()
        logger.info("Certificate is now registered .")
    else:
        logger.info("Certificate is already registered.")
def __create_certificate(certificate_folder, logger):
    """
    Ensures that the certificates are created and registered. If something is amiss, then the
    configuration is fixed.

    :param certificate_folder: Folder where the certificates are stored.
    """

    cert_handler = get_certificate_handler(certificate_folder)

    # We only warn once.
    warned = False
    # Make sure the certificates exist.
    if not cert_handler.exists():
        logger.debug("Certificate doesn't exist on disk.")
        # Start by unregistering certificates from the keychains, this can happen if the user
        # wiped his certificates folder.
        if cert_handler.is_registered():
            # Warn once.
            __warn_for_prompt(removal=False)
            logger.debug("Unregistering dangling certificate from database...")
            warned = True
            cert_handler.unregister()
            logger.debug("Done.")
        # Create the certificate files
        logger.debug("About to create the certificates...")
        cert_handler.create()
        logger.info("Certificate created at %s." % certificate_folder)
    else:
        logger.info("Certificate already exist on disk at %s." % certificate_folder)

    # Check if the certificates are registered with the keychain.
    if not cert_handler.is_registered():
        logger.debug("Certificate is not currently registered in the keychain.")
        # Only if we've never been warned before.
        if not warned:
            __warn_for_prompt(removal=False)
        cert_handler.register()
        logger.info("Certificate is now registered .")
    else:
        logger.info("Certificate is already registered.")