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.

Preguntas Frecuentes

¿Por qué es importante HTTPS para la seguridad de documentos?

HTTPS es crucial para la seguridad de documentos ya que encripta los datos en transferencia, asegurando que la información sensible permanezca confidencial y protegida de intercepciones durante la transmisión.

¿Cómo puedo crear un certificado HTTPS para mi aplicación?

Puede crear un certificado HTTPS ejecutando el comando dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\ironsecuredoc.pfx -p <CREDENTIAL_PLACEHOLDER>, que genera un nuevo certificado para usar con ASP.NET Core.

¿Cómo aseguro que mi certificado HTTPS sea de confianza en mi máquina local?

Para confiar en su certificado HTTPS en su máquina local, use el comando dotnet dev-certs https --trust. Este comando configura su sistema para confiar en el certificado generado.

¿Cuál es el proceso para ejecutar un contenedor Docker con soporte HTTPS?

Para ejecutar un contenedor Docker con soporte HTTPS, exponga ambos puertos HTTP y HTTPS, establezca las variables de entorno necesarias como IronSecureDoc_LicenseKey y CERTIFICATE_PASSWORD, y monte el directorio del certificado como solo lectura.

¿Qué puertos deben configurarse para HTTPS en una configuración Docker?

Para la configuración de HTTPS en una configuración Docker, mapee los puertos del contenedor a los puertos del host exponiendo el puerto 8081 para HTTPS y el puerto 8080 para HTTP.

¿Cómo paso la contraseña del certificado al contenedor Docker?

Pase la contraseña del certificado al contenedor Docker utilizando la variable de entorno CERTIFICATE_PASSWORD al ejecutar el comando Docker run.

¿Qué pasos son necesarios para configurar el entorno como 'Producción' en Docker?

Para configurar el entorno como 'Producción' en Docker, configure la variable de entorno ENVIRONMENT=Production en su comando Docker run.

¿Cómo deben manejarse los marcadores de posición en los comandos Docker?

En los comandos Docker, reemplace los marcadores de posición como <IRONSECUREDOC_LICENSE_KEY> y <CERTIFICATE_PASSWORD> con su clave de licencia de IronSecureDoc y contraseña de certificado para una funcionalidad adecuada.

Curtis Chau
Escritor Técnico

Curtis Chau tiene una licenciatura en Ciencias de la Computación (Carleton University) y se especializa en el desarrollo front-end con experiencia en Node.js, TypeScript, JavaScript y React. Apasionado por crear interfaces de usuario intuitivas y estéticamente agradables, disfruta trabajando con frameworks modernos y creando manuales bien ...

Leer más
¿Listo para empezar?
Versión: 2024.10 recién lanzado