USE HTTPS by Running the Container with a Certificate

This article was translated from English: Does it need improvement?
Translated
View the article in English

If you need to run the container with a certificate, follow these steps to generate the certificate and configure the local machine:

Run the IronSecureDoc Container With a Certificate

  1. Generate Certificate:

    # Generates a new HTTPS certificate for use with ASP.NET Core.
    # Saves the certificate at the specified path and protects it with a password.
    dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\ironsecuredoc.pfx -p <CREDENTIAL_PLACEHOLDER>
    
    # Trusts the generated certificate on your local machine.
    dotnet dev-certs https --trust
    # Generates a new HTTPS certificate for use with ASP.NET Core.
    # Saves the certificate at the specified path and protects it with a password.
    dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\ironsecuredoc.pfx -p <CREDENTIAL_PLACEHOLDER>
    
    # Trusts the generated certificate on your local machine.
    dotnet dev-certs https --trust
    SHELL

    Replace <CREDENTIAL_PLACEHOLDER> with a password.

  2. Run the Docker Container:

    # Runs the IronSecureDoc Docker container with both HTTP and HTTPS ports exposed.
    docker container run -d \
     -p 8081:8081 -p 8080:8080 \ # Maps container ports to host ports for HTTP and HTTPS.
     -e HTTP_PORTS=8080 \ # Sets the HTTP port for the application.
     -e HTTPS_PORTS=8081 \ # Sets the HTTPS port for the application.
     -e IronSecureDoc_LicenseKey=<IRONSECUREDOC_LICENSE_KEY> \ # Provides the IronSecureDoc license key.
     -e ENVIRONMENT=Production \ # Configures the environment as Production.
     -v %USERPROFILE%\.aspnet\https:/https:ro \ # Mounts the directory to the container as read-only.
     -e CERTIFICATE_PATH=%USERPROFILE%\.aspnet\https\ironsecuredoc.pfx \ # Specifies the path to the certificate in the container.
     -e CERTIFICATE_PASSWORD=<CERTIFICATE_PASSWORD> \ # Password for the certificate.
     ironsoftwareofficial/ironsecuredoc:latest # Specifies the Docker image to use.
    # Runs the IronSecureDoc Docker container with both HTTP and HTTPS ports exposed.
    docker container run -d \
     -p 8081:8081 -p 8080:8080 \ # Maps container ports to host ports for HTTP and HTTPS.
     -e HTTP_PORTS=8080 \ # Sets the HTTP port for the application.
     -e HTTPS_PORTS=8081 \ # Sets the HTTPS port for the application.
     -e IronSecureDoc_LicenseKey=<IRONSECUREDOC_LICENSE_KEY> \ # Provides the IronSecureDoc license key.
     -e ENVIRONMENT=Production \ # Configures the environment as Production.
     -v %USERPROFILE%\.aspnet\https:/https:ro \ # Mounts the directory to the container as read-only.
     -e CERTIFICATE_PATH=%USERPROFILE%\.aspnet\https\ironsecuredoc.pfx \ # Specifies the path to the certificate in the container.
     -e CERTIFICATE_PASSWORD=<CERTIFICATE_PASSWORD> \ # Password for the certificate.
     ironsoftwareofficial/ironsecuredoc:latest # Specifies the Docker image to use.
    SHELL

    Replace <IRONSECUREDOC_LICENSE_KEY> and <CERTIFICATE_PASSWORD> with your actual IronSecureDoc license key and certificate password, respectively.

Questions Fréquemment Posées

Pourquoi HTTPS est-il important pour la sécurité des documents ?

HTTPS est essentiel pour la sécurité des documents car il chiffre les données transférées, garantissant que les informations sensibles restent confidentielles et protégées contre l'interception pendant la transmission.

Comment puis-je créer un certificat HTTPS pour mon application ?

Vous pouvez créer un certificat HTTPS en exécutant la commande dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\ironsecuredoc.pfx -p <CREDENTIAL_PLACEHOLDER>, qui génère un nouveau certificat pour une utilisation avec ASP.NET Core.

Comment puis-je m'assurer que mon certificat HTTPS est approuvé sur ma machine locale ?

Pour faire approuver votre certificat HTTPS sur votre machine locale, utilisez la commande dotnet dev-certs https --trust. Cette commande configure votre système pour approuver le certificat généré.

Quel est le processus pour exécuter un conteneur Docker avec prise en charge HTTPS ?

Pour exécuter un conteneur Docker avec prise en charge HTTPS, exposez à la fois les ports HTTP et HTTPS, définissez les variables d'environnement nécessaires telles que IronSecureDoc_LicenseKey et CERTIFICATE_PASSWORD, et montez le répertoire des certificats en lecture seule.

Quels ports doivent être configurés pour HTTPS dans une configuration Docker ?

Pour la configuration HTTPS dans une configuration Docker, mappez les ports du conteneur aux ports de l'hôte en exposant le port 8081 pour HTTPS et le port 8080 pour HTTP.

Comment puis-je transmettre le mot de passe du certificat au conteneur Docker ?

Transmettez le mot de passe du certificat au conteneur Docker en utilisant la variable d'environnement CERTIFICATE_PASSWORD lors de l'exécution de la commande Docker run.

Quelles étapes sont nécessaires pour configurer l'environnement comme 'Production' dans Docker ?

Pour configurer l'environnement comme 'Production' dans Docker, définissez la variable d'environnement ENVIRONMENT=Production dans votre commande Docker run.

Comment les espaces réservés doivent-ils être gérés dans les commandes Docker ?

Dans les commandes Docker, remplacez les espaces réservés tels que <IRONSECUREDOC_LICENSE_KEY> et <CERTIFICATE_PASSWORD> par votre clé de licence IronSecureDoc et votre mot de passe de certificat réels pour un bon fonctionnement.

Curtis Chau
Rédacteur technique

Curtis Chau détient un baccalauréat en informatique (Université de Carleton) et se spécialise dans le développement front-end avec expertise en Node.js, TypeScript, JavaScript et React. Passionné par la création d'interfaces utilisateur intuitives et esthétiquement plaisantes, Curtis aime travailler avec des frameworks modernes ...

Lire la suite
Prêt à commencer?
Version : 2024.10 vient de sortir