Generació d’un certificat autosignat de Azure Application Gateway amb una entitat de certificació arrel personalizadaGenerate an Azure Application Gateway self-signed certificate with a custom root CA

  • 07/23/2019
  • Temps de lectura: 6 minuts
    • v
    • o

La SKU de Application Gateway v2 introdueix l’ús de certificats arrel de confiança per permetre servidors back-end.The Application inici v2 SKU introdueixes the use of Trusted Root Certificates to allow backend servers. D’aquesta manera, es treuen els certificats d’autenticació necessaris en la SKU v1.This Removes authentication certificates that were required in the v1 SKU. El certificat arrel és un certificat arrel en format X.509 (.CER) codificat en base 64 de servidor de certificats de back-end.The root certificate is a Base-64 encoded X.509 (.CER) format root certificate from the backend certificate server. Identifica l’entitat de certificació arrel que va emetre el certificat de servidor que, a continuació, s’usa per a la comunicació TLS / SSL.It identifies the root certificate authority (CA) that issued the server certificate and the server certificate is then used for the TLS / SSL communication.

Application Gateway confia en el certificat del lloc web per defecte si està signat per una entitat de certificació coneguda (per exemple, GoDaddy o DigiCert) .Application inici trusts your website s certificate by default if it ‘s signed by a well-known CA (for example, GoDaddy or DigiCert). En aquest cas, no cal carregar explícitament el certificat raíz.You do not need to explicitly upload the root certificate in that casi. Per a més informació, consulteu Introducció a la terminació TLS i a TLS d’extrem a extrem amb Application Gateway.For more information, see Overview of TLS termination and end to end TLS with Application Gateway. No obstant això, si té un entorn de desenvolupament i proves i no vol comprar cap certificat signat per una entitat de certificació comprovada, pot crear la seva pròpia entitat de certificació personalitzada i crear un certificat autofirmado.However, if you have a dev / test environment and do not want to buy a verified CA signed certificate, you can create your own custom CA and create a self-signed certificate with it.

Nota

Per defecte , els certificats autofirmados no són de confiança i poden ser difícils de mantener.Self-signed certificates are not trusted by default and they can be difficult to maintain. A més, poden utilitzar conjunts hash i de xifrat no actualitzades que podrien no ser seguros.Also, they may use outdated hash and cipher suites that may not be strong. Per millorar la seguretat, compri un certificat signat per una entitat de certificació conocida.For better security, buy a certificate signed by a well-known certificate authority.

En aquest article, aprendrà a: in this article, you will learn how to:

  • Crear la seva pròpia entitat de certificació personalizadaCreate your own custom Certificate Authority
  • Crear un certificat autosignat signat per l’entitat de certificació personalizadaCreate a self-signed certificate signed by your custom CA
  • Carregar un certificat arrel autofirmat a Application Gateway per autenticar el servidor back-endUpload a self-signed root certificate to an Application Gateway to authenticate the backend server

PrerrequisitosPrerequisites

  • OpenSSL en un equip amb Windows o LinuxOpenSSL on a computer running Windows or Linux

    Encara que podria haver altres eines disponibles per a l’administració de certificats, en aquest tutorial es fa servir OpenSSL.While there could be other tools available for certificate management, this tutorial facis servir OpenSSL. Podeu trobar OpenSSL inclòs en moltes distribucions de Linux, com Ubuntu.You can find OpenSSL bundled with many Linux distributions, such as Ubuntu.

  • Un servidor webA web server

    per exemple, Apache, IIS o Nginx per provar els certificados.For example, Apache, IIS, or Nginx to test the certificates.

  • SKU de Application Gateway v2An Application inici v2 SKU

    Si no té cap element de Application Gateway, consulteu Inici ràpid: Direcció de el trànsit web amb Azure Application Gateway: Azure PortalIf you do not have an existing application passarel·la, see Quickstart: Direct web traffic with Azure Application Gateway – Azure portal.

Creació d’un certificat de CA raízCreate a root CA certificate

Creu el certificat d’entitat de certificació arrel amb OpenSSL.Create your root CA certificate using OpenSSL.

Creació de la clau raízCreate the root key

  1. Entreu en l’equip on està instal · lat OpenSSL i executeu el següent comando.Sign in to your computer where OpenSSL is installed and run the following command. Això crea un clau protegida per contraseña.This Creates a password protected key.

    openssl ecparam -out contoso.key -name prime256v1 -genkey
  2. En el símbol de sistema, escriviu una contrasenya segura.At the prompt, type a strong password. Per exemple, a l’almenys nou caràcters, amb majúscules, minúscules, números i símbolos.For example, at least nine characters, using upper case, lower case, numbers, and symbols.

Creació d’un certificat arrel i autofirmadoCreate a Root Certificate and self-sign it

  1. Utilitzeu les ordres següents per generar l’CSR i el certificado.Use the following commands to generate the csr and the certificate.

    openssl req -new -sha256 -key contoso.key -out contoso.csropenssl x509 -req -sha256 -days 365 -in contoso.csr -signkey contoso.key -out contoso.crt

    Les comandes anteriors creen el certificat raíz.The previous commands create the root certificate. El farà servir per signar el certificat de servidor.You’ll usi this to sign your server certificate.

  2. Quan se us demani, introduïu la contrasenya de la clau arrel i la informació de l’organització de l’entitat de certificació personalitzada, com a país o regió, estat, organització, unitat organitzativa i nom de domini complet (és a dir, el domini de l’emissor) .When prompted, type the password for the root key, and the organizational information for the custom CA such as Country / Region, State, Org, OU, and the fully qualified domain name (this is the domain of the issuer).

    creació d'un certificat arrel

Crear un certificat de servidorCreate a server certificate

a continuació, crearà un certificat de servidor amb OpenSSL.Next, you ‘ll create a server certificate using OpenSSL.

Crear la clau de l’certificadoCreate the certificate’ s key

Utilitza la següent comanda per generar la clau pa ra el certificat de servidor.Use the following command to generate the key for the server certificate.

openssl ecparam -out fabrikam.key -name prime256v1 -genkey

Creu la CSR (sol·licitud de signatura de certificats) .Create the CSR (Certificate Signing Request)

La CSR és una clau pública que s’assigna a una entitat de certificació a l’sol·licitar un certificado.The CSR is a public key that is given to a CA when requesting a certificate. L’entitat de certificació emet el certificat per a aquesta sol·licitud específica.The CA issues the certificate for this specific request.

Nota

El nom comú (CN) de l’certificat de servidor ha de ser diferent de l’domini de l’emisor.The CN (Common Name) for the server certificate must be different from the issuer ‘s domain. Per exemple, en aquest cas, el CN de l’emissor és www.contoso.com i el CN d’el certificat de servidor és www.fabrikam.com .For example, in this casi, the CN for the issuer is www.contoso.com and the server certificate ‘s CN is www.fabrikam.com.

  1. Utilitzeu la comanda següent per generar la CSR: Utilitza the following command to generate the CSR:

    openssl req -new -sha256 -key fabrikam.key -out fabrikam.csr
  2. quan se us demani, introduïu la contrasenya de la clau arrel i la informació de l’organització de l’entitat de certificació personalitzada: País o regió, estat, organització, unitat organitzativa i nom de domini completo.When prompted, type the password for the root key, and the organizational information for the custom CA: Country / Region, State, Org, OU, and the fully qualified domain name. Aquest és el domini de la pàgina web i ha de ser diferent de l’emisor.This is the domain of the website and it should be different from the issuer.

    Certificat de servidor

Generació de l’certificat amb la CSR i la clau i firma amb la clau arran de l’entitat de certificaciónGenerate the certificate with the CSR and the key and sign it with the CA ‘s root key

  1. Utilitza la següent comanda per crear el certificat: Utilitza the following command to create the certificate:

    openssl x509 -req -in fabrikam.csr -CA contoso.crt -CAkey contoso.key -CAcreateserial -out fabrikam.crt -days 365 -sha256

Comprovació de l’certificat recentment creadoVerify the newly created certificate

  1. Utilitza la següent comanda per imprimir el resultat de l’arxiu CRT i comprovar el seu contingut: Utilitza the following command to print the output of the CRT file and verify its content:

    openssl x509 -in fabrikam.crt -text -noout

    Comprovació de certificats

  2. Comproveu els arxius de l’adreça tori i segur de tindre els següents arxius: Verify the files in your directory, and ensure you have the following files:

    • contoso.crtcontoso.crt
    • contoso.keycontoso .key
    • fabrikam.crtfabrikam.crt
    • fabrikam.keyfabrikam.key

Configuració de l’certificat en la configuració de TLS de servidor webConfigure the certificate in your web server ‘s TLS settings

Al servidor web , configuri TLS amb els arxius fabrikam.crt i fabrikam.key.In your web server, configuri TLS using the fabrikam.crt and fabrikam.key files. Si el servidor web no pot rebre dos arxius, pot combinar-los en un únic arxiu .pem o .pfx mitjançant comandaments de OpenSSL.If your web server can not take two files, you can combini them to a single .pem or .pfx file using OpenSSL commands.

IISIIS

Per obtenir instruccions sobre com importar el certificat i carregar com un certificat de servidor a l’IIS, consulteu Procediment: Instal·lació de certificats importats en un servidor web en Windows Server 2003.For instructions on how to import certificate and upload them as server certificate on IIS, see hOW tO: Install Imported Certificates on a web server in Windows Server 2003.

Per obtenir instruccions d’enllaç TLS, consulteu configuració de SSL a IIS 7.For TLS binding instructions, see How to Set Up SSL on IIS 7.

ApacheApache

La configuració següent és un exemple d’amfitrió virtual configurat per SSL a Apache: The following configuration is an example virtual host configured for SSL in Apache:

<VirtualHost www.fabrikam:443> DocumentRoot /var/www/fabrikam ServerName www.fabrikam.com SSLEngine on SSLCertificateFile /home/user/fabrikam.crt SSLCertificateKeyFile /home/user/fabrikam.key</VirtualHost>

NGINXNGINX

La configuració següent és un exemple de bloc de servidor Nginx amb configuració de TLS: The following configuration is an example Nginx server bloc with TLS configuration:

Nginx amb TLS

Accés a servidor per comprovar la configuraciónAccess the server to verify the configuration

  1. Afegiu el certificat arrel a l’rèplica de confiança de la máquina.Add the root certificate to your machine ‘s trusted root store. A l’accedir a la pàgina web, assegureu-vos que tota la cadena de certificats es vegi en el explorador.When you access the website, ensure the entire certificate chain is seen in the browser.

    Certificats arrel de confiança

    Nota

    se suposa que el DNS es va configurar perquè apunti el nom de servidor web (en aquest exemple, www. fabrikam.com) a l’adreça IP de servidor web.It ‘s assumed that DNS has been configured to point the web server name (in this example, www.fabrikam.com) to your web server’ s IP address. Si no és així, pot editar el fitxer de host per resoldre el nombre.If not, you can edit the hosts file to resoldrà the name.

  2. Aneu a el seu lloc web i feu clic a la icona de cadenat situat al quadre de direcció de l’explorador per comprovar la informació de el lloc i el certificado.Browse to your website, and clic the lock icon on your browser ‘s address box to verify the site and certificate information.

Comprovació de la configuració amb OpenSSLVerify the configuration with OpenSSL

podeu també utilitzar OpenSSL per comprovar el certificado.Or, you can use OpenSSL to verify the certificate.

openssl s_client -connect localhost:443 -servername www.fabrikam.com -showcerts

Comprovació de certificat OpenSSL

Càrrega de l’ certificat arrel en la configuració HTTP de Application GatewayUpload the root certificate to Application Gateway ‘s HTTP Settings

Per carregar el certificat en Application Gateway, heu d’exportar el certificat .crt c on un format .cer codificat en base 64.To upload the certificate in Application Gateway, you must export the .crt certificate into a .cer format Base-64 encoded. Atès que .crt ja conté la clau pública en el format codificat en base 64, només ha de canviar el nom de l’extensió de l’arxiu de .crt a .cer.Since .crt already contains the public key in the base-64 encoded format , just rename the file extension from .crt to .cer.

Azure PortalAzure portal

Per carregar el certificat arrel de confiança des del portal, seleccioneu Configuració HTTP i triï el protocol HTTPS. to upload the trusted root certificate from the portal, select the HTTP Settings and choose the HTTPS protocol.

Addició d'un certificat mitjançant el portal

Azure PowerShellAzure PowerShell

podeu també utilitzar CLI de Azure o Azure PowerShell per carregar el certificat raíz.Or, you can use Azure CLI or Azure PowerShell to upload the root certificate. El codi següent és un exemple d’Azure PowerShell.The following code is an Azure PowerShell mostra.

Nota

En l’exemple següent s’agrega un certificat arrel de confiança a Application Gateway, es crea una nova configuració de HTTP i s’agrega una nova regla, suposant que el grup de back-end i el client d’escolta ja existeixen.La següent mostra afegeix un certificat arrel de confiança a la passarel·la d’aplicacions, crea un nou entorn HTTP i afegeix una nova regla, suposant que la piscina de backend ja existeix.

## Add the trusted root certificate to the Application Gateway$gw=Get-AzApplicationGateway -Name appgwv2 -ResourceGroupName rgOneAdd-AzApplicationGatewayTrustedRootCertificate ` -ApplicationGateway $gw ` -Name CustomCARoot ` -CertificateFile "C:\Users\surmb\Downloads\contoso.cer"$trustedroot = Get-AzApplicationGatewayTrustedRootCertificate ` -Name CustomCARoot ` -ApplicationGateway $gw## Get the listener, backend pool and probe$listener = Get-AzApplicationGatewayHttpListener ` -Name basichttps ` -ApplicationGateway $gw$bepool = Get-AzApplicationGatewayBackendAddressPool ` -Name testbackendpool ` -ApplicationGateway $gwAdd-AzApplicationGatewayProbeConfig ` -ApplicationGateway $gw ` -Name testprobe ` -Protocol Https ` -HostName "www.fabrikam.com" ` -Path "/" ` -Interval 15 ` -Timeout 20 ` -UnhealthyThreshold 3$probe = Get-AzApplicationGatewayProbeConfig ` -Name testprobe ` -ApplicationGateway $gw## Add the configuration to the HTTP Setting and don't forget to set the "hostname" field## to the domain name of the server certificate as this will be set as the SNI header and## will be used to verify the backend server's certificate. Note that TLS handshake will## fail otherwise and might lead to backend servers being deemed as Unhealthy by the probesAdd-AzApplicationGatewayBackendHttpSettings ` -ApplicationGateway $gw ` -Name testbackend ` -Port 443 ` -Protocol Https ` -Probe $probe ` -TrustedRootCertificate $trustedroot ` -CookieBasedAffinity Disabled ` -RequestTimeout 20 ` -HostName www.fabrikam.com## Get the configuration and update the Application Gateway$backendhttp = Get-AzApplicationGatewayBackendHttpSettings ` -Name testbackend ` -ApplicationGateway $gwAdd-AzApplicationGatewayRequestRoutingRule ` -ApplicationGateway $gw ` -Name testrule ` -RuleType Basic ` -BackendHttpSettings $backendhttp ` -HttpListener $listener ` -BackendAddressPool $bepoolSet-AzApplicationGateway -ApplicationGateway $gw 

Comprovació del Estado de back-end de la instantia de l’aplicació GatewayVerify the Application Gateway Backend Health

  1. Haga Clic en la Vista Estado de Back-end de la Instancia de l’aplicació Gateway para Compropar Si l’Estado del Sondeig es corregeix. Feu clic a la vista de la salut del backend de la passarel·la de la vostra aplicació per comprovar si la sonda és saludable.
  2. Debería ver que l’estado es corregeix per a el sondeo https.you ha de veure que l’estat és saludable per a la sonda https.

sondeo https

para obtener más información sobre ssl ssl ss en aplicació Gateway, Consulte Introducció a la terminació TLS YA TLS DE EXTER A L’APLICACIÓ EXTERO CON CONSULTE Gateway.To Més informació sobre SSL TLS a la passarel·la d’aplicacions, vegeu Visió general de TLS TERMINACIÓ i FINALITZAR TLS END TLS AMB PORTAT D’APLICACIÓ.

Deixa un comentari

L'adreça electrònica no es publicarà. Els camps necessaris estan marcats amb *