Condividi tramite


Risoluzione dei problemi di sicurezza

 

Si applica a: Windows Azure Pack

Questo argomento descrive la risoluzione dei problemi relativi alla sicurezza e all'autenticazione in Windows Azure Pack per Windows Server. Molti problemi possono essere risolti esaminando l'elenco di controllo Credenziali in questo argomento. Sono disponibili raccomandazioni per i problemi seguenti:

  • Dopo l'integrazione di AD FS, reimpostare il portale di gestione per l'uso di AD

  • Dopo l'integrazione di AD FS, non è possibile accedere al portale tenant

  • Ottenere un token con il cmdlet Get-MgmtSvcToken

  • Usare a livello di codice i certificati tenant

  • Sostituire un certificato autofirmato con un certificato attendibile

  • Risolvere gli avvisi del certificato

  • Accedere al portale di gestione da più account

  • Esaminare le impostazioni SSL/TLS

Elenco di controllo delle credenziali

L'elenco di controllo seguente fornisce le procedure consigliate per la configurazione di certificati, nomi utente e password per Windows Azure Pack e per i prodotti e i provider usati.

  • Per i test o i componenti non connessi a Internet, ad esempio il portale di gestione per amministratori o api Amministrazione, è possibile usare l'autorità di certificazione Microsoft per creare certificati autofirmato.

  • Per i componenti con connessione Internet, ad esempio il portale di gestione per i tenant e l'API pubblica tenant, usare un'autorità di certificazione pubblica attendibile.

  • Configurare le identità del pool di applicazioni per Service Provider Foundation in Internet Information Services (IIS) nel server che esegue Service Provider Foundation in modo che usino l'account delle credenziali utente di dominio. L'uso di Servizi di rete non è consigliato.

  • Configurare le identità del pool di applicazioni nei server che eseguono System Center 2012 R2 Virtual Machine Manager e Service Provider Foundation per usare lo stesso account di dominio con diritti di accesso come servizio .

  • Configurare Service Provider Foundation per usare l'autenticazione di base in IIS.

  • Configurare un account utente locale con diritti amministrativi per essere membro di VMM, Amministrazione, provider e gruppi di utilizzo nel server che esegue Service Provider Foundation. Usare questo account utente locale per registrare l'endpoint Service Provider Foundation con Windows Azure Pack per Windows Server.

Per altre informazioni, vedere il post di blog Risoluzione dei problemi di Windows Azure Pack, Service Provider Foundation & Virtual Machine Manager. Per una panoramica dei servizi Web Service Provider Foundation, vedere Gestire i servizi Web e Connections in Service Provider Foundation. Vedere anche Panoramica dell'autenticazione di Windows Azure Pack.

Dopo l'integrazione di AD FS, non è possibile accedere al portale tenant

Riguarda: Configurare Active Directory Federation Services per Windows Azure Pack

Problema

La schermata di accesso del tenant non viene visualizzata dopo la configurazione di AD FS (Active Directory Federation Services) o non può accedere al portale di gestione per i tenant.

Consiglio

Dopo aver integrato AD FS nel dominio in cui è installato Windows Azure Pack, la pagina di accesso viene ignorata direttamente nel portale. Si tratta del comportamento previsto del browser.

Se non è possibile accedere al portale di gestione per i tenant, usare Server Manager per eseguire ADSI Edit e verificare che il server AD SF abbia un nome dell'entità servizio (SPN) è elencato. Il nome SPN deve essere sotto forma di http/myADFSServer.

Torna all'inizio

Dopo l'integrazione di AD FS, reimpostare il portale di gestione per l'uso di AD

Riguarda: Configurare Active Directory Federation Services per Windows Azure Pack

Problema

Si vuole tornare all'uso di Active Directory (AD) per il portale di gestione, dopo l'integrazione di Active Directory Federation Services (AD FS).

Consiglio

È necessario ristabilire l'attendibilità tra il portale di gestione per gli amministratori e il sito di autenticazione di Windows come è stato fatto per AD FS. Il sito autenticazione di Windows è la porta 30072. È possibile usare i cmdlet Windows PowerShell Set-MgmtSvcRelyingPartySettigns e Set-MgmtSvcIdentityProviderSettings.

Ottenere un token con il cmdlet Get-MgmtSvcToken

Riguarda: Windows Azure Pack per Automazione di Windows Server con Windows PowerShell

Problema

Il Get-MgmtSvcToken non restituisce il token come previsto.

Consiglio

Potrebbe verificarsi un problema con il cmdlet Get-MgmtSvcToken che non usa correttamente Active Directory Federation Services (AD FS). Lo script seguente definisce una funzione, Get-AdfsToken, come soluzione alternativa.

function Get-AdfsToken([string]$adfsAddress, [PSCredential]$credential)
{
    $clientRealm = 'http://azureservices/AdminSite'
    $allowSelfSignCertificates = $true

    Add-Type -AssemblyName 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    Add-Type -AssemblyName 'System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

    $identityProviderEndpoint = New-Object -TypeName System.ServiceModel.EndpointAddress -ArgumentList ($adfsAddress + '/adfs/services/trust/13/usernamemixed')
    $identityProviderBinding = New-Object -TypeName System.ServiceModel.WS2007HttpBinding -ArgumentList ([System.ServiceModel.SecurityMode]::TransportWithMessageCredential)
    $identityProviderBinding.Security.Message.EstablishSecurityContext = $false
    $identityProviderBinding.Security.Message.ClientCredentialType = 'UserName'
    $identityProviderBinding.Security.Transport.ClientCredentialType = 'None'

    $trustChannelFactory = New-Object -TypeName System.ServiceModel.Security.WSTrustChannelFactory -ArgumentList $identityProviderBinding, $identityProviderEndpoint
    $trustChannelFactory.TrustVersion = [System.ServiceModel.Security.TrustVersion]::WSTrust13

    if ($allowSelfSignCertificates)
    {
        $certificateAuthentication = New-Object -TypeName System.ServiceModel.Security.X509ServiceCertificateAuthentication
        $certificateAuthentication.CertificateValidationMode = 'None'
        $trustChannelFactory.Credentials.ServiceCertificate.SslCertificateAuthentication = $certificateAuthentication
    }

    $ptr = [System.Runtime.InteropServices.Marshal]::SecureStringToCoTaskMemUnicode($credential.Password)
    $password = [System.Runtime.InteropServices.Marshal]::PtrToStringUni($ptr)
    [System.Runtime.InteropServices.Marshal]::ZeroFreeCoTaskMemUnicode($ptr)

    $trustChannelFactory.Credentials.SupportInteractive = $false
    $trustChannelFactory.Credentials.UserName.UserName = $credential.UserName
    $trustChannelFactory.Credentials.UserName.Password = $password #$credential.Password

    $rst = New-Object -TypeName System.IdentityModel.Protocols.WSTrust.RequestSecurityToken -ArgumentList ([System.IdentityModel.Protocols.WSTrust.RequestTypes]::Issue)
    $rst.AppliesTo = New-Object -TypeName System.IdentityModel.Protocols.WSTrust.EndpointReference -ArgumentList $clientRealm
    $rst.TokenType = 'urn:ietf:params:oauth:token-type:jwt'
    $rst.KeyType = [System.IdentityModel.Protocols.WSTrust.KeyTypes]::Bearer

    $rstr = New-Object -TypeName System.IdentityModel.Protocols.WSTrust.RequestSecurityTokenResponse

    $channel = $trustChannelFactory.CreateChannel()
    $token = $channel.Issue($rst, [ref] $rstr)

    $tokenString = ([System.IdentityModel.Tokens.GenericXmlSecurityToken]$token).TokenXml.InnerText;
    $result = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($tokenString))
    return $result
}

# Fill in values
$adfsAddress = 'https://adfshost'
$username = 'domain\username'
$password = 'password'
$securePassword = ConvertTo-SecureString -String $password -AsPlainText -Force
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username,$securePassword

$token = Get-AdfsToken -adfsAddress $adfsAddress -credential $credential 
$token

Torna all'inizio

Usare a livello di codice i certificati tenant

Per quanto riguarda: Guida per sviluppatori di Service Provider Foundation

Problema

È necessario creare un certificato e caricarlo nel portale di gestione per i tenant e quindi poterlo usare a livello di codice.

Consiglio

Utilizzare la procedura seguente:

  1. Creare un certificato (può essere autofirmato). Deve avere un'estensione di file .cer .

  2. Nella pagina Account personale del portale di gestione per i tenant fare clic su Certificati di gestione.

  3. Passare il certificato nell'intestazione della richiesta all'API pubblica tenant per l'autenticazione, come illustrato nell'esempio seguente.

    Nota

    Sarà possibile accedere solo alla sottoscrizione assegnata a questo certificato. Non sarà possibile eliminare la sottoscrizione tramite l'API pubblica del tenant.

    X509Certificate2 mycert3 = new X509Certificate2("C:\\WorkDocs\\Test\\Management Certs\\myCert.cer");
    HttpClient httpClient = new HttpClient();
    var handler = new WebRequestHandler();
    handler.ClientCertificates.Add(mycert3);
    handler.PreAuthenticate = true;
    httpClient = new HttpClient(handler);
    
    string tenantPublicEndpoint = "https://test.fabrikam.com:30006/";
    string subscriptionid = " 7d31eb89-bb1e-4b16-aa3c-993f978b6bc1";
    
    string subscriptionEndpoint = tenantPublicEndpoint + subscriptionid+ "/services/webspaces/defaultwebspace/sites";
    var response = httpClient.GetAsync(subscriptionEndpoint);
    var resultsStr = response.Result.Content.ReadAsStringAsync().Result;
    

Torna all'inizio

Sostituire un certificato autofirmato con un certificato attendibile

Riguarda: Amministrare Windows Azure Pack per Windows Server

Problema

Dopo aver usato un certificato autofirmato per un ambiente di test, si vuole sostituire il certificato con quello rilasciato da un'autorità attendibile.

Consiglio

Installare il certificato nell'archivio personale del computer locale e eseguire il mapping del certificato a ogni sito Web in Internet Information Services (IIS). Il certificato deve soddisfare i requisiti seguenti:

  • Provengono da un'autorità di certificazione attendibile

  • Avere un intervallo di date valido

  • Fornire un'istruzione di utilizzo e scopo valida

  • Fornire l'autenticazione del server

  • Corrisponde al nome di dominio del certificato con il nome del sito Web

  • Avere una crittografia a 1024 bit RSA o superiore

  • Includere la chiave privata

Torna all'inizio

Risolvere gli avvisi del certificato

Riguarda:Distribuire Windows Azure Pack per Windows Server

Problema

Avvisi di certificato persistenti con il certificato da un'autorità attendibile.

Consiglio

Alcuni browser non elaborano il campo autorità di accesso alle informazioni che si trova nel certificato durante la convalida del certificato. La soluzione alternativa consiste nell'installare in modo esplicito i certificati intermedi nell'archivio certificati. Per un elenco di autorità di certificazione che supportano questo campo, vedere Windows e Windows Phone 8 Ssl Root Certificate Program (Member CAs).

Torna all'inizio

Esaminare le impostazioni SSL/TLS

Riguarda:Distribuire Windows Azure Pack per Windows Server

Problema

La sicurezza di comunicazione debole può causare un'inondazione di errori Schannel visualizzati nel registro eventi di sistema.

Consiglio

Per migliorare la sicurezza dei canali di comunicazione di Windows Azure Pack, è consigliabile aggiornare le impostazioni SSL/TLS. Prima di implementare queste modifiche, è necessario assicurarsi che non influiscano su altre applicazioni o servizi.

È possibile eseguire lo script seguente in ogni computer che esegue Windows Azure Pack per apportare queste modifiche:

# PowerShell script to secure TLS/SSL settings.
# Copyright (c) Microsoft Corporation. All rights reserved.
# 20-Jun-2015 Update-ComputerSchannelSettings.ps1

<#
.Synopsis
   Apply HTTP.SYS settings
.NOTES
   Reference: Http.sys registry settings for Windows
   https://support.microsoft.com/en-us/kb/820129
#>
function Set-HttpSysSettings()
{
    Write-Verbose -Message "$($Myinvocation.MyCommand.Name)" -Verbose

    $regPath = "HKLM:\System\CurrentControlSet\Services\HTTP\Parameters"

    # Read original values.
    $maxFieldLength = (Get-ItemProperty -Path $regPath -Name MaxFieldLength -ErrorAction SilentlyContinue).MaxFieldLength
    $maxRequestBytes = (Get-ItemProperty -Path $regPath -Name MaxRequestBytes -ErrorAction SilentlyContinue).MaxRequestBytes
    Write-Verbose -Message "HTTP.SYS settings:`r`n  MaxFieldLength = $maxFieldLength`r`n  MaxRequestBytes = $maxRequestBytes" -Verbose

    # Is update needed?
    if ($maxFieldLength -ne 32KB -or $maxRequestBytes -ne 32KB)
    {
        # Write updated values.
        Set-ItemProperty -Path $regPath -Name MaxFieldLength -Value 32KB
        Set-ItemProperty -Path $regPath -Name MaxRequestBytes -Value 32KB

        # Read updated values.
        $maxFieldLength = (Get-ItemProperty -Path $regPath -Name MaxFieldLength).MaxFieldLength
        $maxRequestBytes = (Get-ItemProperty -Path $regPath -Name MaxRequestBytes).MaxRequestBytes
        Write-Verbose -Message "HTTP.SYS settings (updated):`r`n  MaxFieldLength = $maxFieldLength`r`n  MaxRequestBytes = $maxRequestBytes" -Verbose

        # Changes that are made to the registry will not take effect until you restart the HTTP service.
        Write-Warning -Message "HTTP.SYS settings updated; restarting the HTTP service."
        Restart-Service -Name "http" -Force -Verbose
    }

    return $false # No reboot needed.
}

<#
.Synopsis
   Apply SSL configuration settings (TLS Cipher Suite Ordering)
.NOTES
   Reference: Prioritizing Schannel Cipher Suites
   https://msdn.microsoft.com/en-us/library/windows/desktop/bb870930(v=vs.85).aspx
#>
function Set-SchannelCipherOrder()
{
    Write-Verbose -Message "$($Myinvocation.MyCommand.Name)" -Verbose
    $reboot = $false

    $regPath = "HKLM:\SOFTWARE\Policies\Microsoft\Cryptography\Configuration\SSL\00010002"

    # The ordered suites names need to be specified as a single string (REG_SZ)
    # with each suite separated by commas and with no embedded spaces.
    # The list of cipher suites is limited to 1023 characters.
    $cipherOrder = @(
        'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384_P384'
        'TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256_P256'
        'TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384'
        'TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256'
        'TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384'
        'TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA_P256'
        'TLS_RSA_WITH_AES_256_GCM_SHA384'
        'TLS_RSA_WITH_AES_128_GCM_SHA256'
        'TLS_RSA_WITH_AES_256_CBC_SHA256'
        'TLS_RSA_WITH_AES_128_CBC_SHA256'
        'TLS_RSA_WITH_AES_256_CBC_SHA'
        'TLS_RSA_WITH_AES_128_CBC_SHA'
    )
    $cipherOrderList = ($cipherOrder -join ',')

    # Read original values.
    $functions = (Get-ItemProperty -Path $regPath -Name Functions -ErrorAction SilentlyContinue).Functions
    Write-Verbose -Message "Schannel Cipher Order:`r`n  Functions = $($functions -split ',' | ConvertTo-Json)" -Verbose

    # Is update needed?
    if ($functions -ne ($cipherOrder -join ','))
    {
        # Write updated values.
        Set-ItemProperty -Path $regPath -Name Functions -Value $cipherOrderList -Force

        # Read updated values.
        $functions = (Get-ItemProperty -Path $regPath -Name Functions -ErrorAction SilentlyContinue).Functions
        Write-Verbose -Message "Schannel Cipher Order (updated):`r`n  Functions = $($functions -split ',' | ConvertTo-Json)" -Verbose

        # It is necessary to restart the computer after modifying this setting for the changes to take effect.
        Write-Warning -Message "Schannel Cipher Order updated; it is necessary to restart the computer."
        $reboot = $true ### TODO: Restart-Computer -Force -Verbose
    }

    return $reboot
}
<#
.Synopsis
   Apply TLS Protocol version configuration
.NOTES
   Reference: How to Disable SSL 3.0 in Azure Websites, Roles, and Virtual Machines
   https://azure.microsoft.com/blog/2014/10/19/how-to-disable-ssl-3-0-in-azure-websites-roles-and-virtual-machines/
#>
function Set-SchannelProtocols()
{
    Write-Verbose -Message "$($Myinvocation.MyCommand.Name)" -Verbose
    $reboot = $false

    $regPath = "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols"
    $protocolSettings = @(
        [PSCustomObject]@{ Path = "$regPath\SSL 2.0\Client"; Name = "Enabled"; Value = 0 }
        [PSCustomObject]@{ Path = "$regPath\SSL 2.0\Server"; Name = "Enabled"; Value = 0 }
        [PSCustomObject]@{ Path = "$regPath\SSL 3.0\Client"; Name = "Enabled"; Value = 0 }
        [PSCustomObject]@{ Path = "$regPath\SSL 3.0\Server"; Name = "Enabled"; Value = 0 }
        [PSCustomObject]@{ Path = "$regPath\TLS 1.0\Client"; Name = "Enabled"; Value = 1 }
        [PSCustomObject]@{ Path = "$regPath\TLS 1.0\Server"; Name = "Enabled"; Value = 1 }
        [PSCustomObject]@{ Path = "$regPath\TLS 1.1\Client"; Name = "Enabled"; Value = 1 }
        [PSCustomObject]@{ Path = "$regPath\TLS 1.1\Server"; Name = "Enabled"; Value = 1 }
        [PSCustomObject]@{ Path = "$regPath\TLS 1.2\Client"; Name = "Enabled"; Value = 1 }
        [PSCustomObject]@{ Path = "$regPath\TLS 1.2\Server"; Name = "Enabled"; Value = 1 }
    )

    # Read original values.
    $currentProtocolSettings = @()
    foreach ($protocolSetting in $protocolSettings)
    {
        $value = (Get-ItemProperty -Path $protocolSetting.Path -Name $protocolSetting.Name -ErrorAction SilentlyContinue).$($protocolSetting.Name)
        $currentProtocolSettings += [PSCustomObject]@{ Path = $protocolSetting.Path; Name = $protocolSetting.Name; Value = $value }
    }
    Write-Verbose -Message "Schannel Protocol Settings: $($currentProtocolSettings | Format-Table -Autosize | Out-String)" -Verbose

    $observed = $currentProtocolSettings | ConvertTo-Json -Compress
    $expected = $protocolSettings | ConvertTo-Json -Compress

    # Is update needed?
    if ($observed -ne $expected)
    {
        # Create registry nodes.
        $protocolPaths = @(
            "$regPath\SSL 2.0"
            "$regPath\SSL 2.0\Client"
            "$regPath\SSL 2.0\Server"
            "$regPath\SSL 3.0"
            "$regPath\SSL 3.0\Client"
            "$regPath\SSL 3.0\Server"
            "$regPath\TLS 1.0"
            "$regPath\TLS 1.0\Client"
            "$regPath\TLS 1.0\Server"
            "$regPath\TLS 1.1"
            "$regPath\TLS 1.1\Client"
            "$regPath\TLS 1.1\Server"
            "$regPath\TLS 1.2"
            "$regPath\TLS 1.2\Client"
            "$regPath\TLS 1.2\Server"
        )
        foreach ($protocolPath in $protocolPaths)
        {
            if (-not (Get-Item -Path $protocolPath -ErrorAction SilentlyContinue))
            {
                New-Item -Path $protocolPath -ItemType Container -Force | Out-Null
            }
        }

        # Write updated values.
        foreach ($protocolSetting in $protocolSettings)
        {
            Set-ItemProperty -Path $protocolSetting.Path -Name $protocolSetting.Name -Value $protocolSetting.Value -Force
        }

        # Read updated values.
        $currentProtocolSettings = @()
        foreach ($protocolSetting in $protocolSettings)
        {
            $value = (Get-ItemProperty -Path $protocolSetting.Path -Name $protocolSetting.Name -ErrorAction SilentlyContinue).$($protocolSetting.Name)
            $currentProtocolSettings += [PSCustomObject]@{ Path = $protocolSetting.Path; Name = $protocolSetting.Name; Value = $value }
        }
        Write-Verbose -Message "Schannel Protocol Settings (updated): $($currentProtocolSettings | Format-Table -Autosize | Out-String)" -Verbose

        # It is necessary to restart the computer after modifying this setting for the changes to take effect.
        Write-Warning -Message "Schannel Protocols updated; it is necessary to restart the computer."
        $reboot = $true ### TODO: Restart-Computer -Force -Verbose
    }

    return $reboot
}

#-------------------------------------------------------------------------------
# Main

$reboot = $false
$reboot += Set-HttpSysSettings
$reboot += Set-SchannelCipherOrder
$reboot += Set-SchannelProtocols
if ($reboot)
{
    Write-Warning -Message "Restart the computer for settings to take effect."
    # TODO: Restart-Computer -Force -Verbose
}

È anche possibile eseguire strumenti di convalida SSL/TLS per identificare altre aree per migliorare.

Torna all'inizio

Accedere al portale di gestione da più account

Si riferisce a: Windows Azure Pack per l'automazione di Windows Server con Windows PowerShell

Problema

È necessario poter accedere al portale di gestione da più account.

Consiglio

Usare il cmdlet Add-MgmtSvcAdminUser Windows PowerShell per aggiungere altre entità. Queste entità possono essere utenti o gruppi di sicurezza espliciti (se i token contengono informazioni sul gruppo di sicurezza). Nell'esempio seguente viene aggiunto un utente. Si presuppone che la password sia stata definita per la variabile $pwd.

Add-MgmtSvcAdminUser -Server 'mysqlserver' -UserName 'sa' -Password $pwd -Principal 'user7@contoso.com'

Torna all'inizio

Vedere anche

Risoluzione dei problemi di Windows Azure Pack