

Die vorliegende Übersetzung wurde maschinell erstellt. Im Falle eines Konflikts oder eines Widerspruchs zwischen dieser übersetzten Fassung und der englischen Fassung (einschließlich infolge von Verzögerungen bei der Übersetzung) ist die englische Fassung maßgeblich.

# Beenden von HTTPS auf EC2 Amazon-Instances, auf denen .NET ausgeführt wird
<a name="SSLNET.SingleInstance"></a>

Die folgende [Konfigurationsdatei](ebextensions.md) erstellt und führt ein PowerShell Windows-Skript aus, das die folgenden Aufgaben ausführt:
+ Überprüft, ob ein vorhandenes HTTPS-Zertifikat an Port 443 gebunden ist.
+ Ruft das [PFX-Zertifikat](configuring-https-ssl.md) aus einem Amazon S3 S3-Bucket ab.
**Anmerkung**  
Fügen Sie eine `AmazonS3ReadOnlyAccess` Richtlinie für den `aws-elasticbeanstalk-ec2-role` Zugriff auf das SSL-Zertifikat im Amazon S3 S3-Bucket hinzu.
+ Ruft das Passwort von ab AWS Secrets Manager.
**Anmerkung**  
Fügen Sie eine Anweisung hinzu`aws-elasticbeanstalk-ec2-role`, die die `secretsmanager:GetSecretValue` Aktion für das Geheimnis ermöglicht, das das Zertifikatspasswort enthält
+ Installiert das Zertifikat.
+ Bindet das Zertifikat an Port 443.
**Anmerkung**  
Um den HTTP-Endpunkt (Port 80) zu entfernen, fügen Sie den `Remove-WebBinding`-Befehl unter dem Abschnitt **Remove the HTTP binding** des Beispiels hinzu.

**Example .ebeextensions/ .config https-instance-dotnet**  

```
files:
  "C:\\certs\\install-cert.ps1":
    content: |
      import-module webadministration
      ## Settings - replace the following values with your own
      $bucket = "amzn-s3-demo-bucket"  ## S3 bucket name
      $certkey = "example.com.pfx"    ## S3 object key for your PFX certificate
      $secretname = "example_secret"  ## AWS Secrets Manager name for a secret that contains the certificate's password
      ##

      # Set variables
      $certfile = "C:\cert.pfx"
      $pwd = Get-SECSecretValue -SecretId $secretname | select -expand SecretString

      # Clean up existing binding
      if ( Get-WebBinding "Default Web Site" -Port 443 ) {
        Echo "Removing WebBinding"
        Remove-WebBinding -Name "Default Web Site" -BindingInformation *:443:
      }
      if ( Get-Item -path IIS:\SslBindings\0.0.0.0!443 ) {
        Echo "Deregistering WebBinding from IIS"
        Remove-Item -path IIS:\SslBindings\0.0.0.0!443
      }

      # Download certificate from S3
      Read-S3Object -BucketName $bucket -Key $certkey -File $certfile
      
      # Install certificate
      Echo "Installing cert..."
      $securepwd = ConvertTo-SecureString -String $pwd -Force -AsPlainText
      $cert = Import-PfxCertificate -FilePath $certfile cert:\localMachine\my -Password $securepwd
      
      # Create site binding
      Echo "Creating and registering WebBinding"
      New-WebBinding -Name "Default Web Site" -IP "*" -Port 443 -Protocol https
      New-Item -path IIS:\SslBindings\0.0.0.0!443 -value $cert -Force
      
      ## Remove the HTTP binding
      ## (optional) Uncomment the following line to unbind port 80
      # Remove-WebBinding -Name "Default Web Site" -BindingInformation *:80:
      ##
      
      # Update firewall
      netsh advfirewall firewall add rule name="Open port 443" protocol=TCP localport=443 action=allow dir=OUT

commands:
  00_install_ssl:
    command: powershell -NoProfile -ExecutionPolicy Bypass -file C:\\certs\\install-cert.ps1
```

In einer einzelnen Instance-Umgebung müssen Sie außerdem die Sicherheitsgruppe der Instance ändern, damit Datenverkehr über Port 443 zugelassen wird. Die folgende Konfigurationsdatei ruft mithilfe einer CloudFormation [Funktion](ebextensions-functions.md) die ID der Sicherheitsgruppe ab und fügt ihr eine Regel hinzu.

**Example .ebeextensions/ .config https-instance-single**  

```
Resources:
  sslSecurityGroupIngress: 
    Type: AWS::EC2::SecurityGroupIngress
    Properties:
      GroupId: {"Fn::GetAtt" : ["AWSEBSecurityGroup", "GroupId"]}
      IpProtocol: tcp
      ToPort: 443
      FromPort: 443
      CidrIp: 0.0.0.0/0
```

[In einer Umgebung mit Lastenausgleich konfigurieren Sie den Load Balancer so, dass er entweder [sicheren Datenverkehr unangetastet weiterleitet oder zur Verschlüsselung entschlüsselt und erneut](https-tcp-passthrough.md) verschlüsselt.](configuring-https-endtoend.md) end-to-end