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.

Häufig gestellte Fragen

Warum ist HTTPS wichtig für die Dokumentensicherheit?

HTTPS ist entscheidend für die Dokumentensicherheit, da es die übertragenen Daten verschlüsselt, wodurch sichergestellt wird, dass sensible Informationen vertraulich bleiben und während der Übertragung vor Abfangung geschützt sind.

Wie kann ich ein HTTPS-Zertifikat für meine Anwendung erstellen?

Sie können ein HTTPS-Zertifikat erstellen, indem Sie den Befehl dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\ironsecuredoc.pfx -p <CREDENTIAL_PLACEHOLDER> ausführen, der ein neues Zertifikat zur Verwendung mit ASP.NET Core generiert.

Wie stelle ich sicher, dass mein HTTPS-Zertifikat auf meinem lokalen Rechner vertrauenswürdig ist?

Um Ihr HTTPS-Zertifikat auf Ihrem lokalen Rechner zu vertrauen, verwenden Sie den Befehl dotnet dev-certs https --trust. Dieser Befehl konfiguriert Ihr System so, dass es das generierte Zertifikat vertraut.

Wie läuft der Prozess zum Ausführen eines Docker-Containers mit HTTPS-Unterstützung ab?

Um einen Docker-Container mit HTTPS-Unterstützung auszuführen, exponieren Sie sowohl HTTP- als auch HTTPS-Ports, setzen Sie die notwendigen Umgebungsvariablen wie IronSecureDoc_LicenseKey und CERTIFICATE_PASSWORD, und binden Sie das Zertifikatsverzeichnis als schreibgeschützt ein.

Welche Ports sollten für HTTPS in einer Docker-Setup konfiguriert werden?

Für die HTTPS-Konfiguration in einer Docker-Setup, weisen Sie die Containerports den Hostports zu, indem Sie Port 8081 für HTTPS und Port 8080 für HTTP exponieren.

Wie übermittle ich das Zertifikat-Passwort an den Docker-Container?

Übergeben Sie das Zertifikat-Passwort mithilfe der Umgebungsvariable CERTIFICATE_PASSWORD, wenn Sie den Docker-Run-Befehl ausführen.

Welche Schritte sind erforderlich, um die Umgebung in Docker als 'Produktion' zu konfigurieren?

Um die Umgebung in Docker als 'Produktion' zu konfigurieren, legen Sie die Umgebungsvariable ENVIRONMENT=Production in Ihrem Docker-Run-Befehl fest.

Wie sollten Platzhalter in Docker-Befehlen behandelt werden?

In Docker-Befehlen ersetzen Sie Platzhalter wie <IRONSECUREDOC_LICENSE_KEY> und <CERTIFICATE_PASSWORD> durch Ihren tatsächlichen IronSecureDoc-Lizenzschlüssel und das Zertifikat-Passwort für die ordnungsgemäße Funktionalität.

Curtis Chau
Technischer Autor

Curtis Chau hat einen Bachelor-Abschluss in Informatik von der Carleton University und ist spezialisiert auf Frontend-Entwicklung mit Expertise in Node.js, TypeScript, JavaScript und React. Leidenschaftlich widmet er sich der Erstellung intuitiver und ästhetisch ansprechender Benutzerschnittstellen und arbeitet gerne mit modernen Frameworks sowie der Erstellung gut strukturierter, optisch ansprechender ...

Weiterlesen
Bereit anzufangen?
Version: 2024.10 gerade veröffentlicht