CertificateValidation/Microsoft.AzureStack.CertificateValidation.psm1

<#############################################################
 # #
 # Copyright (C) Microsoft Corporation. All rights reserved. #
 # #
 #############################################################>


<#
 
.SYNOPSIS
This module is intended to be given to the customer along with their deploymentdata.json
in order to validate the certificates are suitable before Azure Stack deployment.
 
.DESCRIPTION
The validation checks the following:
    Read PFX. Checks for valid PFX file, correct password and warns if public information is not protected by the password.
    Signature Algorithm. Checks the Signature Algorithm is not SHA1
    Private Key. Checks the private key is present and is exported with the Local Machine attribute.
    Cert Chain. Checks certificate chain is in tact including for self-signed certificates.
    DNS Names. Checks the SAN contains relevant DNS names for each endpoint or if a supporting wildcard is present.
    Key Usage. Checks Key Usage contains Digital Signature and Key Encipherment and Enhanced Key Usage contains Server Authentication and Client Authentication.
    Key Size. Checks Key Size is 2048 or larger
    Chain Order. Checks the order of the other certificates making the chain is correct.
    Other Certificates. Ensure no other certificates have been packaged in PFX other than the relevant leaf certificate and its chain.
    No Profile. Checks a new user can load the PFX data without a user profile loaded, mimicking the behavior of gMSA accounts during certificate servicing.
 
 
.EXAMPLE
To Check certificates are ready for install run the following:
Import-Module .\Microsoft.AzureStack.CertificateValidation.psm1
$password = Read-Host -Prompt "Enter PFX Password" -AsSecureString
Start-CertChecker -CertificatePath .\Certificates\ -pfxPassword $password -deploymentDataJSONPath .\DeploymentData.json
 
To import/export certificates as indicated by the output of the above command
Import-Module .\Microsoft.AzureStack.CertificateValidation.psm1
$password = Read-Host -Prompt "Enter PFX Password" -AsSecureString
Start-CertChecker -pfxPassword $password -pfxPath \certificates\acsblob\old_sslblob.pfx -ExportToPath \certificates\acsblob\new_sslblob.pfx [<CommonParameters>]
 
.NOTES
The script expects the certificates in the same directory structure as the install: i.e.
\Certificates\
    \ACSblob
        \ssl.pfx
    \ADFS
        \ssl.pfx
The script requires the deploymentdata.json that will be used for deployment.
 
.LINK
 
#>


$mod = Import-Module $PSScriptRoot\PublicCertHelper.psd1 -Force -PassThru
Import-Module $PSScriptRoot\..\Microsoft.AzureStack.ReadinessChecker.Utilities.psm1 -Force
#setting global variable to true
$GLOBAL:standalone = $true
$ErrorActionPreference = 'Stop'

function Test-AzsCertificatePlacement {
    param ($certificatePath, $certConfig, $UseADFS)
    $thisFunction = $MyInvocation.MyCommand.Name
    # set expected folder names
    $validContainers = $certConfig.Keys | Foreach-Object {$PSITEM}
    if ($validContainers.count -eq 1) {
        if ($validContainers -eq (Split-Path $certificatePath -leaf)) {
            Write-AzsReadinessLog -message ("Single container expected: {0}" -f ($validContainers)) -Type Info -Function $thisFunction
            $folders = (Get-Item -Path $certificatePath)
            $actualContainers = (Get-Item -Path $certificatePath).Name
        }
        else {
            Write-AzsReadinessLog -Message ("Invalid folder name used {0}, expecting {1}. Please correct the folder name and retry. Exiting." -f (Split-Path -Path $certificatePath -leaf),$validContainers) -Type Error -Function $thisFunction -toScreen
            break
        }
    }
    elseif ($validContainers.count -gt 1) {
        Write-AzsReadinessLog -message ("Multiple containers found. Checking for folders: {0}" -f ($validContainers -join ',')) -Type Info -Function $thisFunction
        # Check directory structure is valid
        $actualContainers = (Get-ChildItem -Path $certificatePath -Directory).Name
        $folders = (Get-ChildItem -Path $certificatePath -Directory)
        if (-not $actualContainers) {
            Write-AzsReadinessLog -message ("Invalid folder structure found in certificate folder {0}, ensure only required folders are present. `nRequired folders: {1}" -f `
                $CertificatePath, `
                ($validContainers -join ', ')`
            ) -Type Error -Function $thisFunction -toScreen
            break
        }
    }
    else {
        Write-AzsReadinessLog -Message "Unable to determine expected certificate placement. Exiting." -Type Error -Function $thisFunction
        break
    }

    $compareContainers = Compare-Object -ReferenceObject $validContainers -DifferenceObject $actualContainers
    if ($compareContainers) {
        $invalidContainers = $compareContainers | Where-Object SideIndicator -eq '=>' | Select-Object -ExpandProperty InputObject
        $missingContainers = $compareContainers | Where-Object SideIndicator -eq '<=' | Select-Object -ExpandProperty InputObject
        if (-not $invalidContainers) {$invalidContainers = '[none]'}
        if (-not $missingContainers) {$missingContainers = '[none]'}
        Write-AzsReadinessLog -Message ("Invalid folder structure found in certificate folder {0}, ensure only required folders are present. `nRequired folders: {1} `nInvalid folders: {2} `nMissing folders: {3}" -f `
                $CertificatePath, `
            ($validContainers -join ', '), `
            ($invalidContainers -join ', '), `
            ($missingContainers -join ', ')
        ) -Type Error -Function $thisFunction -toScreen
        Write-AzsReadinessLog -Message 'Expected folder structure is as follows:' -Type Info -Function $thisFunction -toScreen
        Write-AzsReadinessLog -Message "`t$certificatePath" -Type Info -Function $thisFunction -toScreen
        $i = 0
        foreach ($key in $certConfig.keys) {
            $i++
            Write-AzsReadinessLog -Message "`t +--$key" -Type Info -Function $thisFunction -toScreen
            if ($i -lt $certConfig.Keys.count) {
                Write-AzsReadinessLog -Message "`t | \-<customFileName>.pfx" -Type Info -Function $thisFunction -toScreen
            }
            else {
                Write-AzsReadinessLog -Message "`t \-<customFileName>.pfx" -Type Info -Function $thisFunction -toScreen
            }
        }
        Write-AzsReadinessLog -Message "`nCorrect the folder structure and rerun validation." -Type Info -Function $thisFunction -toScreen
        break
    }
    else {
        Write-AzsReadinessLog -Message "Folder structure verified." -Type Info -Function $thisFunction
    }

    # Check there is only a single cert in each folder
    foreach ($folder in $folders) {
        Set-PFXPlacement -path $folder.fullname -certConfig $certConfig
    }
}

function Invoke-AzsCertificateValidation {
    <#
    .SYNOPSIS
        Invoke-Microsoft.AzureStack.CertificateValidation is a standalone wrapper for "certchecker"
    .DESCRIPTION
        Either invokes certificate validation for Azure Stack public certificates or
        import/export routine to correct Azure Stack public certificates
    .EXAMPLE
        $pfxPassword = Read-Host -Prompt "Enter PFX Password" -AsSecureString
        $certificateValidationParams = @{
            CertificateType = 'Deployment'
            certificatepath = "$ENV:USERPROFILE\Documents\AzureStack\Certificates\Deployment"
            pfxPassword = $pfxPassword
            RegionName = 'east'
            ExternalFQDN = 'azurestack.contoso.com'
            IdentitySystem = 'AAD'
        }
        Invoke-AzsCertificateValidation @certificateValidationParams
        Validates multiple certificates are ready for Azure Stack Deployment and Secret Rotation.
    .EXAMPLE
        $pfxPassword = Read-Host -Prompt "Enter PFX Password" -AsSecureString
        $certificateValidationParams = @{
            CertificateType = 'Deployment'
            certificatepath = "$ENV:USERPROFILE\Documents\AzureStack\Certificates\Deployment"
            pfxPassword = $pfxPassword
            DeploymentDataJSONPath = "$ENV:USERPROFILE\Documents\AzureStack\DeploymentData.json"
        }
        Invoke-AzsCertificateValidation @certificateValidationParams
        Validates multiple certificates are ready for Azure Stack Deployment and Secret Rotation using the DeploymentData.json.
    .EXAMPLE
        $pfxPassword = Read-Host -Prompt "Enter PFX Password" -AsSecureString
        $certificateValidationParams = @{
            CertificateType = 'AppServices'
            certificatepath = "$ENV:USERPROFILE\Documents\AzureStack\Certificates\AppServices"
            pfxPassword = $pfxPassword
            RegionName = 'east'
            ExternalFQDN = 'azurestack.contoso.com'
        }
        Invoke-AzsCertificateValidation @certificateValidationParams
        Validates multiple Certificates are ready for AppServices and Azure Stack. Requires certificates in folders DefaultDomain, API, Publishing, Identity respectively.
    .EXAMPLE
        $pfxPassword = Read-Host -Prompt "Enter PFX Password" -AsSecureString
        $certificateValidationParams = @{
            CertificateType = 'IoTHub'
            certificatepath = "$ENV:USERPROFILE\Documents\AzureStack\Certificates\IoTHub"
            pfxPassword = $pfxPassword
            RegionName = 'east'
            ExternalFQDN = 'azurestack.contoso.com'
        }
        Invoke-AzsCertificateValidation @certificateValidationParams
        Validates single Certificates are ready for IoTHub and Azure Stack. Also applicable to EventHubs, DBAdapter and DataboxEdge certificate types.
    .EXAMPLE
        $customCertConfig = @{
            'NWTradersRP' = @{
                DNSName = @('*.nwtraders','admin.nwtraders')
                KeyLength = 4096
            }
            'TailSpinRP' = @{
                DNSName = @('*.tailspin')
                HashAlgorithm = 'SHA386'
            }
        }
 
        $certificateValidationParams = @{
            CustomCertConfig = $customCertConfig
            certificatepath = "$ENV:USERPROFILE\Documents\AzureStack\Certificates\CustomRPs"
            pfxPassword = $pfxPassword
            RegionName = 'east'
            ExternalFQDN = 'azurestack.contoso.com'
        }
        Invoke-AzsCertificateValidation @certificateValidationParams
        Validates multiple Certificates. Each single certificates should be placed in a subfolder (of CertificatePath) named the same as the key in the custom hashtable e.g. NWTraderRP and TailSpinRP as in the example.
    .EXAMPLE
        $pfxPassword = Read-Host -Prompt "Enter PFX Password" -AsSecureString
        $certificateValidationParams = @{
            CertificateType = 'AzureStackEdgeDevice'
            DeviceName = 'DBG-KARB2NP5J'
            NodeSerialNumber = 'WIN-KARB2NP5J3O'
            certificatepath = "$ENV:USERPROFILE\Documents\AzureStack\Certificates\AzureStackEdgeDevice"
            pfxPassword = $pfxPassword
            ExternalFQDN = 'azurestack.contoso.com'
        }
        Invoke-AzsCertificateValidation @certificateValidationParams
        Validates multiple certificates are ready for Azure Stack Edge device certificates.
    .PARAMETER CertificateType
        Specifies the Azure Stack certificate type to generate a request for e.g. Deployment, AppServices, EventHubs, IoTHub etc.
    .PARAMETER CertificatePath
        Path to directory structure for Azure Stack Public Certificates.
        The path given for this parameter is expected to contain one of the following sets of sub-directories, each with a single pfx certificate:
        Identity System AAD:
            ACSBlob, ACSQueue, ACSTable, Admin Portal, ARM Admin, ARM Public, KeyVault, KeyVaultInternal, Public Portal
        Identity System ADFS:
            ADFS, Graph, ACSBlob, ACSQueue, ACSTable, Admin Portal, ARM Admin, ARM Public, KeyVault, KeyVaultInternal, Public Portal
    .PARAMETER pfxPassword
        A securestring containing a single password that is common across all certificates
    .PARAMETER deploymentDataJSONPath
        Specifies the Azure Stack deployment deployment data JSON configuration file. Generally only available to the deployment team.
    .PARAMETER ExternalFQDN
        Specifies the Azure Stack deployment's External FQDN, also aliased as ExternalFQDN and ExternalDomainName, must be valid DNSHostName
    .PARAMETER RegionName
        Specifies the Azure Stack deployment's region name when deploymentdata.json is not used, must be alphanumeric.
    .PARAMETER DeviceName
        Specifies the Device Name of an Azure Stack Edge device.
    .PARAMETER NodeSerialNumber
        Specifies the node serial number(s) of an Azure Stack Edge device.
    .PARAMETER IdentitySystem
        Specifies the Azure Stack deployment's Identity System valid values, AAD or ADFS, for Azure Active Directory and Active Directory Federated Services respectively
    .PARAMETER CustomCertConfig
        Specifies a custom hashtable for custom validation. Minimum required info: @{'CertificateName' = @{DNSName= @('*.rpnamespace')}} where DNSName declared everything left of region.domain.com.
    .PARAMETER CleanReport
        Specifies whether to purge the existing report and start again with a clean report. Execution history and validation data is lost for all Readiness Checker validations.
    .PARAMETER OutputPath
        Specifies custom path to save Readiness JSON report and Verbose log file.
    .LINK
        Deployment Certificate Validation - https://aka.ms/AzsValidateCerts
        PaaS Certificate Validation - https://aka.ms/AzsValidatePaaSCerts
        Azure Stack Readiness Checker Tool - https://aka.ms/AzsReadinessChecker
    #>

    [CmdletBinding()]
    [Alias("Start-CertChecker", "Start-AzsCertChecker", "Start-AzureStackCertChecker", "CertChecker", "Invoke-AzureStackCertificateValidation")]
    Param(
        [Parameter(Mandatory = $true, HelpMessage = "Specify the Azure Stack certificate type to generate a request")]
        [ArgumentCompleter({Get-AzsCertificateTypes | Sort-Object})]
        [ValidateScript({$_ -in (Get-AzsCertificateTypes)})]
        [string]
        $CertificateType,

        [Parameter(Mandatory=$true,HelpMessage="Enter Path to Certificates Directory")]
        [ValidateScript( {Test-Path $_ -PathType Container})]
        [string]
        $CertificatePath,

        [ValidatePattern('(?# Region must be alphanumeric)^[a-zA-Z0-9]+$')]
        [string]
        $RegionName,

        [Alias("ExternalDomainName", "FQDN")]
        [ValidateScript( {[System.Uri]::CheckHostName($_) -eq 'dns' <#FQDN must be valid DNSHostName#>})]
        [string]
        $ExternalFQDN,

        [Parameter(Mandatory = $true, HelpMessage = "Enter Password for PFX Certificates as a secure string" )]
        [ValidateScript({`
            Test-PasswordLength -MinimumCharactersInPassword 8 -Password $PSITEM -CredentialDescription 'pfxPassword'
            Test-PasswordComplexity -Password $PSITEM -CredentialDescription 'pfxPassword'
        })]
        [securestring]
        $pfxPassword,

        [ValidateScript( {Test-Path $_ -Include *.json})]
        [string]
        $deploymentDataJSONPath,

        [Parameter(HelpMessage="Enter Azure Stack Edge Device Name")]
        [string]
        $DeviceName,

        [Parameter(HelpMessage="Enter Azure Stack Edge Node Serial Number")]
        [string[]]
        $NodeSerialNumber,

        [Parameter(HelpMessage="Enter Azure Stack Hub deployment identity system, AAD or ADFS.")]
        [ValidateSet('AAD', 'ADFS')]
        [string]
        $IdentitySystem,

        [hashtable]
        $customCertConfig,

        [Parameter(HelpMessage = "Directory path for log and report output")]
        [string]$OutputPath = "$ENV:TEMP\AzsReadinessChecker",

        [Parameter(HelpMessage = "Remove all previous progress and create a clean report")]
        [switch]$CleanReport = $false
    )
    process {
        try {
            $thisFunction = $MyInvocation.MyCommand.Name
            $GLOBAL:OutputPath = $OutputPath
            # Get/Clean Existing Report
            Import-Module $PSScriptRoot\..\Microsoft.AzureStack.ReadinessChecker.Reporting.psm1 -Force
            Write-Header -invocation $MyInvocation -params $PSBoundParameters
            $readinessReport = Get-AzsReadinessProgress -clean:$CleanReport
            $readinessReport = Add-AzsReadinessCheckerJob -report $readinessReport

            # Ensure we are elevated
            if (Test-Elevation)
            {
                Write-AzsReadinessLog -Message ("Powershell running as Administrator. Continuing.") -Type Info
            }
            else
            {
                Write-AzsReadinessLog -Message ("Running as administrator is required for this operation. `nPlease restart PowerShell as Administrator and retry.") -Type Error -toScreen
                Write-AzsReadinessLog -Message ("This is because certificate validation must load sensitive key material in order to validate all required certificate attributes.") -Type Error -toScreen
                throw "This operation requires elevation."
            }

            # Check the user provided appropriate parameters
            # NodeSerialNumber is AzureStackEdgeDevice
            if ($certificateType -eq 'AzureStackEdgeDevice' -and !$NodeSerialNumber) {
                throw "CertificateType is $certificateType and NodeSerialNumber not provided. Please re-run providing -NodeSerialNumber and the appropriate value for your system."
            }

            if ($deploymentDataJSONPath) {
                # detect deployment type, get region name and fqdn, and set useADFS flag and directory name
                $deploymentDataJSON = ConvertTo-DeploymentData -path $deploymentDataJSONPath
                $RegionName = $deploymentDataJSON.DeploymentData.RegionName
                $externalFQDN = $deploymentDataJSON.DeploymentData.ExternalDomainFQDN
                if ($deploymentDataJSON.DeploymentData.UseAdfs) {
                    $UseADFS = $true
                    $dirName = 'ADFS'
                }
                elseif ($deploymentDataJSON.DeploymentData.InfraAzureEnvironment) {
                    $UseADFS = $false
                    $dirName = 'AAD'
                }
                else {
                    Write-Error -message "Failed to parse identity store in DeploymentJSON"
                }
            }
            else {
                switch ($IdentitySystem) {
                    'ADFS' { $UseADFS = $true; $dirName = 'ADFS' }
                    'AAD' { $UseADFS = $false; $dirName = 'AAD' }
                }
            }

            # Join RegionName and ExternalFQDN
            if ($regionName -and $CertificateType -ne 'AzureStackEdgeDevice') {
                    $ExternalFQDN = "{0}" -f (($regionName,$ExternalFQDN) -join '.')
            }

            # Get certificate Config
            if ($customCertConfig) {
                # Test custom cert structure
                $customCertConfig = Test-CustomCertConfig -customCertConfig $customCertConfig
                if (-not $customCertConfig) {
                    Write-AzsReadinessLog -Message "Please correct the custom certificate configuration and retry." -Type Error -Function $thisFunction -toScreen
                    break
                }
                $certConfig = $customCertConfig
            }
            else {
                # Get declared configs
                $CertificateType = $PSBoundParameters.CertificateType
                $certificateConfigDataFile = Import-PowerShellDataFile -Path $PSScriptRoot\Microsoft.AzureStack.CertificateConfig.psd1
                $certConfig = $certificateConfigDataFile.CertificateTypes[$certificateType]
                if (-not $UseADFS) {
                    $certConfig.Remove('Graph')
                    $certConfig.Remove('ADFS')
                }
            }

            # Add support for multiple multi node Edge device (NodeSerialNumbers)
            # Split them in to their own folders
            if ($certificateType -in 'AzureStackEdgeDevice' -and $NodeSerialNumber.count -gt 1) {
                Write-AzsReadinessLog -Message "Configuring multi-node Edge device validation. Finding DNS matches for nodeserialnumbers in PFXs present" -Type Info
                Import-Module $PSScriptRoot\PublicCertHelper.psm1 -Force
                $num = 0
                $PSBoundParameters.nodeSerialNumber | ForEach-Object {
                    $newNode = $certConfig.node.Clone()
                    $nodeKey = "Node{0:d2}" -f $num
                    $certConfig.Add($nodeKey,$newNode)
                    $certConfig[$nodeKey].DnsName = $PSITEM
                    $num++

                    $edgeNodePfxs = Get-ChildItem -Path $CertificatePath\Node -filter *.pfx
                    foreach ($edgeNodePfx in $edgeNodePfxs) {
                        $certificate = Get-PFXData -FilePath $edgeNodePfx.fullname -Password $pfxPassword | Select-Object -ExpandProperty EndEntityCertificates
                        $testDNSNames = Test-DNSNames -cert $Certificate -ExpectedDomain $ExternalFQDN -certConfig $certConfig[$nodeKey]
                        if ($testDNSNames.Result -eq 'OK') {
                            # copy pfx
                            Write-AzsReadinessLog -Message "DNS match found for $PSITEM." -Type Info
                            New-Item -Path "$CertificatePath\$nodeKey" -Force -ItemType Directory | Out-Null
                            Copy-Item -Path $edgeNodePfx.FullName -Destination ("{0}\{1}\{2}" -f $CertificatePath,$nodeKey,$edgeNodePfx.Name)
                            break
                        }
                        else {
                            Write-AzsReadinessLog -Message "DNS match not found for $PSITEM. Ensure all required Node certificates are in Node folder" -Type Error
                        }
                    }
                }

                if ((Get-ChildItem -path $CertificatePath\Node*).count -ne ($num + 1)) {
                    Write-AzsReadinessLog "Ensure all required Node certificates are in Node folder"  -Type Error -ToScreen
                    throw "Ensure all required Node certificates are in Node folder"
                }
                # Finally remove the Node from the config
                $certConfig.remove('Node')
                # Backup a previous execution instead of overwriting and move the original directory to TEMP for the during of the validation
                if (Test-Path $ENV:Temp\AzsReadinessChecker\Node) {
                    Move-Item -Path $ENV:Temp\AzsReadinessChecker\Node -Destination ("{0}{1}" -f "$ENV:Temp\AzsReadinessChecker\Node",(Get-Date -f 'yyyyMMddHHmmss')) -Force
                }
                Move-Item -Path $CertificatePath\Node -Destination $ENV:Temp\AzsReadinessChecker\Node -Force
            }

            # Validate certificate placement (single cert in one folder for single certs, multiple correctly named folders for multiple certs (e.g. infra/AppServices))
            Test-AzsCertificatePlacement -UseADFS:$UseADFS -certificatePath $CertificatePath -certConfig $certConfig

            #Validate any certificates
            Write-Log -Message ("Starting Azure Stack {0} Certificate Validation {1} " -f $certificateType[0],$mod.Version) -Type Info -Function $thisfunction -toScreen
            $TestAzsCertificatesResults = foreach ($key in $certConfig.keys) {
                # Handle SANs for Azure Stack Edge certificates with DeviceName and Node serial numbers instead of regionname and fqdn
                # Append region & fqdn to dnsname for the rest
                Write-AzsReadinessLog -Message ("Getting pfx content {0}" -f $certConfig.$key.pfxPath) -Type Info -Function $thisFunction
                if ((Get-Command Get-Content).Parameters.AsByteStream) {
                    [byte[]]$pfxBinary = Get-Content -Path $certConfig.$key.pfxPath -AsByteStream
                }
                else {
                    [byte[]]$pfxBinary = Get-Content -Path $certConfig.$key.pfxPath -Encoding Byte
                }
                if (-not $pfxBinary) {
                    Write-AzsReadinessLog -Message ("Invalid PFX {0}" -f $certConfig.$key.pfxPath) -Type Error -Function $thisFunction
                }
                # Handle SANs for AzureStackEdgeDevice appliance certificates with DeviceName and NodeSerialNumbers
                # Append region & fqdn to dnsname for the rest
                $AzureStackEdgeDeviceApplianceCertificates = $certificateConfigDataFile.CertificateTypes.AzureStackEdgeDevice.Keys + `
                                                                $certificateConfigDataFile.CertificateTypes.AzureStackEdgeVPN.Keys
                if ($key -in $AzureStackEdgeDeviceApplianceCertificates) {
                    $certConfig.$key.DNSName = $certConfig.$key.DNSName | Foreach-Object { `
                        $PSITEM.replace('[[DeviceName]]',$DeviceName).replace('[[NodeSerialNumber]]',$NodeSerialNumber)
                    } | Sort-Object
                    $TestAzsRPCertificatesResult = Test-AzsCertificate -CertificateBinary $pfxBinary -CertificatePassword $pfxPassword -ExpectedDomainFQDN $externalFQDN -certConfig $certConfig.$key
                }
                else {
                    $TestAzsRPCertificatesResult = Test-AzsCertificate -CertificateBinary $pfxBinary -CertificatePassword $pfxPassword -ExpectedDomainFQDN $externalFQDN -certConfig $certConfig.$key
                }
                $TestAzsRPCertificatesResult
            }
            # Copy the log certchecker log for now, until migration can occur.
            Copy-AzsReadinessLogging -ComponentLogFile CertChecker

            # Write results to readiness report
            $readinessReport.CertificateValidation.$certificateType = $TestAzsCertificatesResults
            $readinessReport = Close-AzsReadinessCheckerJob -report $readinessReport
            $readinessReport.CertificateValidation.$certificateType = Test-CertificateReuse -validationResult $readinessReport.CertificateValidation.$certificateType
        }
        catch {
            Write-AzsReadinessLog -message ("Certificate Validation failed with error: {0}" -f $_.exception.message) -Type Error
            throw
        }
        finally {
            Write-AzsReadinessProgress -report $readinessReport
            Write-AzsReadinessReport -report $readinessReport
            Write-Footer -invocation $MyInvocation

            # Restore users original folders
            if ($certificateType -in 'AzureStackEdgeDevice' -and $NodeSerialNumber.count -gt 1) {
                Move-Item $ENV:TEMP\AzsReadinessChecker\Node -Destination $CertificatePath\Node -ErrorAction SilentlyContinue
                $NodeTempPath = Get-ChildItem -Path $CertificatePath -Filter Node* -Directory | Where-Object Name -ne 'Node' | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue
            }
        }
    }
}

function Repair-AzsPfxCertificate {
    <#
    .SYNOPSIS
        Re-package PFX files to remediate common packaging problems
    .DESCRIPTION
        Import PFX into local machine store, export the package ensuring chain export, encryption usage etc
    .EXAMPLE
        PS C:\> Repair-AzsPfxCertificate -PfxPassword $pfxPassword -PfxPath .\certificates\ACSBlob\ACSBlob.pfx -ExportPFXPath .\certificates\ACSBlob\ACSBlob_new.pfx
        Import ACSBlob PFX and re-exports it to the same folder with a new name.
    .PARAMETER PfxPassword
        Specifies the password associated with PFX certificate files.
    .PARAMETER PfxPath
        Specifies the path to a problematic certificate that requires import/export routine to fix, as indicated by certificate validation in this tool
    .PARAMETER ExportPFXPath
        Specifies the destination path for the resultant PFX file from import/export routine.
    .PARAMETER OutputPath
        Specifies custom path to save Readiness JSON report and Verbose log file.
    .LINK
        Remediate common issues for Azure Stack PKI certificates - https://aka.ms/AzsRemediateCerts
        Azure Stack Readiness Checker Tool - https://aka.ms/AzsReadinessChecker
    #>

    [CmdletBinding()]
    Param(
        [Parameter(Mandatory = $false, HelpMessage = "Enter Password for PFX Certificates as a secure string")]
        [ValidateScript({`
            Test-PasswordLength -MinimumCharactersInPassword 8 -Password $PSITEM -CredentialDescription 'pfxPassword'
            Test-PasswordComplexity -Password $PSITEM -CredentialDescription 'pfxPassword'
        })]
        [securestring]
        $pfxPassword,

        [Parameter(Mandatory = $true, HelpMessage = "Path to PFX on disk", ParameterSetName = "ImportExport")]
        [ValidateScript( {Test-Path $_ -Include *.pfx -PathType Leaf})]
        [string]
        $pfxPath,

        [Parameter(Mandatory = $true, HelpMessage = "Destination Path for PFX export", ParameterSetName = "ImportExport")]
        [ValidateScript( {Test-Path -Path (split-path -Path $_ -Parent)})]
        [string]
        $ExportPFXPath,

        [Parameter(HelpMessage = "Directory path for log")]
        [string]$OutputPath = "$ENV:TEMP\AzsReadinessChecker"
    )

    $thisFunction = $MyInvocation.MyCommand.Name
    $GLOBAL:OutputPath = $OutputPath
    Import-Module $PSScriptRoot\..\Microsoft.AzureStack.ReadinessChecker.Reporting.psm1 -Force
    Write-Header -invocation $MyInvocation -params $PSBoundParameters

    # Ensure we are elevated
    if (Test-Elevation)
    {
        Write-AzsReadinessLog -Message ("Powershell running as Administrator. Continuing.") -Type Info
    }
    else
    {
        Write-AzsReadinessLog -Message ("Running as administrator is required for this operation. `nPlease restart PowerShell as Administrator and retry.") -Type Error -toScreen
        Write-AzsReadinessLog -Message ("This is because sensitive key material must be accessed in order to re-package certificates.") -Type Error -toScreen
        throw "This operation requires elevation."
    }

    Write-AzsReadinessLog -Message ("Starting Azure Stack Certificate Import/Export") -Type Info -Function $thisfunction -toScreen
    Write-AzsReadinessLog -Message "Importing PFX $pfxPath into Local Machine Store" -Type Info -Function $thisfunction -toScreen
    $certificate = Import-AzsCertificate -pfxPath $pfxPath -pfxPassword $pfxPassword
    if (-not $certificate) {
        Write-AzsReadinessLog -Message "Import Failed. Please review log." -Type Error -Function $thisfunction -toScreen
    }
    else {
        Write-AzsReadinessLog -Message "Exporting certificate to $exportPFXPath" -Type Info -Function $thisfunction -toScreen
        Export-AzsCertificate -filePath $ExportPFXPath -certPath $certificate -pfxPassword $pfxPassword
        Write-AzsReadinessLog -Message "Export complete. Removing certificate from the local machine store." -Type Info -Function $thisfunction -toScreen
        Remove-Item $certificate.pspath -Force
        if (-not (Test-Path $certificate.pspath)) {
            Write-AzsReadinessLog -Message "Removal complete." -Type Info -Function $thisfunction -toScreen
        }
        else {
            Write-AzsReadinessLog -Message ("Removal incomplete. Please manually remove {0}." -f $certificate.pspath) -Type Warning -Function $thisfunction -toScreen
        }
    }
    Copy-AzsReadinessLogging -ComponentLogFile CertChecker
    Write-Footer -invocation $MyInvocation
}

function Set-PFXPlacement {
    # checks for a single certificate and sets pfxPath in the certConfig
    param ($path,$certConfig)
    $thisFunction = $MyInvocation.MyCommand.Name
    $pfxfiles = Get-ChildItem $path -Filter *.pfx -ErrorAction SilentlyContinue
    if ($pfxfiles.count -ne 1) {
        Write-AzsReadinessLog -Message ("The certificate path '{0}' should only contain 1 PFX certificate. {1} PFX files found. `nEnsure all certificate folders only contain a single certificate." -f $path, $pfxfiles.count) -Type Error -Function $thisFunction -toScreen
        break
    }
    else {
        Write-AzsReadinessLog -Message ("Single PFX found with name '{0}'. Setting pfxPath in certConfig." -f $pfxfiles.FullName) -Type Info -Function $thisFunction
        $certConfig.$($pfxfiles.Directory.Name).pfxPath = $pfxfiles.FullName
    }
}

function Test-CustomCertConfig {
    param ([hashtable]$customCertConfig)
    if ($customCertConfig -isnot [HashTable]) {
        Write-AzsReadinessLog -Message ("Custom Cert Config is not a valid hashtable. `nExpecting at least: `n@{'CertificateName' = @{DNSName= @('*.certificate.domain')}}.") -Type Error -Function $thisfunction -toScreen
        return $false
    }

    foreach ($customCertName in $customCertConfig.Keys) {
        $customCertHash = $customCertConfig.$customCertName
        # Check its a hashtable
        if ($customCertHash -isnot [HashTable]) {
            Write-AzsReadinessLog -Message ("Custom Cert {0} is not a valid hashtable. `nExpecting at least: `n@{'CertificateName' = @{DNSName= @('*.certificate.domain')}}." -f $customCertName) -Type Error -Function $thisfunction -toScreen
            return $false
        }
        else {
            $hashToString = ($customCertHash.GetEnumerator() | ForEach-Object { "$($_.Key)=$($_.Value)" }) -join '; '
            Write-AzsReadinessLog -Message ("Custom Cert is a valid hashtable @{{{0} = @{{{1}}}}}" -f $customCertName,$hashToString) -Type Info -Function $thisfunction
        }

        # Check it has at least a DNSName
        if (-not $customCertHash.DNSName){
            Write-AzsReadinessLog -Message ("Custom cert {0} must contain at least DNSName key. Exiting." -f $customCertName)  -Type Error -Function $thisfunction -toScreen
            return $false
        }
        else {
            Write-AzsReadinessLog -Message ("Custom Config {0} contains DNSName to check" -f $customCertName) -Type Info -Function $thisfunction
        }

        # Add include and exclude test if they're not present
        if (-not $customCertHash.IncludeTests) {
            Write-AzsReadinessLog -Message ("Custom Config {0}. Adding IncludeTests as 'All'" -f $customCertName) -Type Info -Function $thisfunction
            $customCertConfig.$customCertName.IncludeTests = 'All'
        }
        else {
            Write-AzsReadinessLog -Message ("Custom Config {0}. IncludeTests contains {1}" -f $customCertName, $customCertHash.IncludeTests) -Type Info -Function $thisfunction
        }
        if (-not $customCertHash.ExcludeTests) {
            Write-AzsReadinessLog -Message ("Custom Config {0}. Adding ExcludeTests as 'CNG Key'" -f $customCertName) -Type Info -Function $thisfunction
            $customCertConfig.$customCertName.ExcludeTests = 'CNG Key'
        }
        else {
            Write-AzsReadinessLog -Message ("Custom Config {0}. ExcludeTests contains {1}" -f $customCertName, $customCertHash.ExcludeTests) -Type Info -Function $thisfunction
        }
    }
    $customCertConfig
}

function New-AzsCertificateFolder {
    <#
    .SYNOPSIS
        Create folder structure Azure Stack Certificates
    .DESCRIPTION
        Create folder structure Azure Stack Certificates
    .EXAMPLE
        New-AzsCertificateFolder -certificateType Deployment -IdentitySystem AAD -OutputPath C:\SecureStore\AzureStack
        Create Deployment Folders in C:\SecureStore\AzureStack\Deployment
    .EXAMPLE
        New-AzsCertificateFolder -certificateType AppServices -OutputPath C:\SecureStore\AzureStack
        Create AppServices Folders in C:\SecureStore\AzureStack\AppServices
    .EXAMPLE
        New-AzsCertificateFolder -certificateType EventHubs -OutputPath C:\SecureStore\AzureStack
        Create EventHubs Folders in C:\SecureStore\AzureStack\EventHubs
    .EXAMPLE
        New-AzsCertificateFolder -certificateType IoTHub -OutputPath C:\SecureStore\AzureStack
        Create IoTHub Folders in C:\SecureStore\AzureStack\IoTHub
    .EXAMPLE
        New-AzsCertificateFolder -certificateType DataboxEdge -OutputPath C:\SecureStore\AzureStack
        Create DataboxEdge Folders in C:\SecureStore\AzureStack\DataboxEdge
    .EXAMPLE
        New-AzsCertificateFolder -certificateType AzureStackEdgeDevice -OutputPath C:\SecureStore\AzureStack
        Create Azure Stack Edge Folders in C:\SecureStore\AzureStack\AzureStackEdgeDevice
    .EXAMPLE
        New-AzsCertificateFolder -certificateType DBAdapter -OutputPath C:\SecureStore\AzureStack
        Create DBAdapter Folders in C:\SecureStore\AzureStack\DBAdapter
    #>

    [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')]
    param (
        [Parameter(Mandatory = $true, HelpMessage = "Specify the Azure Stack certificate type to generate a request")]
        [ArgumentCompleter({Get-AzsCertificateTypes | Sort-Object})]
        [ValidateScript({$_ -in (Get-AzsCertificateTypes)})]
        [string]
        $CertificateType,

        [Parameter(Mandatory = $true, HelpMessage = "Destination Path for Certificate")]
        [string]$OutputPath,

        [Parameter(Mandatory = $false, HelpMessage = "Enter Azure Stack Identity System (AAD or ADFS) when generating deployment certificates")]
        [ValidateSet('AAD', 'ADFS')]
        [string]$IdentitySystem
    )
    process
    {
        try {
            # Get Certificate Config
            $certificateConfigDataFile = Import-PowerShellDataFile -Path $PSScriptRoot\..\CertificateValidation\Microsoft.AzureStack.CertificateConfig.psd1
            $certificateConfig = $certificateConfigDataFile.CertificateTypes[$CertificateType]
            if ($certificateType -eq 'Deployment' -AND $IdentitySystem -ne 'ADFS') {
                        $certificateConfig.Remove('Graph')
                        $certificateConfig.Remove('ADFS')
            }

            # Create Folder Structure
            if ($certificateConfig.Keys.count -eq 1) {
                $destination = $OutputPath
            }
            else{
                $destination = Join-Path -Path $OutputPath -ChildPath $CertificateType
            }
            Foreach ($key in $certificateConfig.keys) {
                $newFolder = Join-Path -Path $destination -ChildPath $key
                New-Item -Path $newFolder -ItemType Directory -Force
            }
        }
        catch {
            throw $_.exception
        }
    }
}

function Get-AzsCertificateTypes {
    param ([string[]]$certificateTypeExclusions = @('Hardware'))
    $certificateConfigDataFile = Import-PowerShellDataFile -Path $PSScriptRoot\Microsoft.AzureStack.CertificateConfig.psd1
    $certificateTypes = $certificateConfigDataFile.CertificateTypes | Select-Object -ExpandProperty Keys | Where-Object {$PSITEM -notin $certificateTypeExclusions}
    $certificateTypes + 'Custom' | Sort-Object
}

function Invoke-AzsEdgeDeviceCertificateValidation {
    <#
    .SYNOPSIS
        Run certificate validation for Azure Stack Edge Device Certificates
    .DESCRIPTION
        Calls Invoke-AzsCertificateValidation with neccessary parameters to validate Azure Stack Edge Device certificates
    .EXAMPLE
        $pfxPassword = Read-Host -Prompt "Enter PFX Password" -AsSecureString
        $certificateValidationParams = @{
            DeviceName = 'DBG-KARB2NP5J'
            NodeSerialNumber = 'WIN-KARB2NP5J3O'
            certificatepath = "$ENV:USERPROFILE\Documents\AzureStack\Certificates\AzureStackEdgeDevice"
            pfxPassword = $pfxPassword
            ExternalFQDN = 'azurestack.contoso.com'
        }
        Invoke-AzsEdgeDeviceCertificateValidation @certificateValidationParams
        Run certificate validation for Azure Stack Edge Device Certificates
    .EXAMPLE
        $pfxPassword = Read-Host -Prompt "Enter PFX Password" -AsSecureString
        $certificateValidationParams = @{
            DeviceName = 'DBG-KARB2NP5J'
            NodeSerialNumber = 'WIN-KARB2NP5J3O','WIN-GBWB7ML4K9O'
            certificatepath = "$ENV:USERPROFILE\Documents\AzureStack\Certificates\AzureStackEdgeDevice"
            pfxPassword = $pfxPassword
            ExternalFQDN = 'azurestack.contoso.com'
        }
        Invoke-AzsEdgeDeviceCertificateValidation @certificateValidationParams
        Run certificate validation for multi-node Azure Stack Edge Device Certificates
    .PARAMETER CertificatePath
        Path to directory structure for Azure Stack Edge Device Certificates.
    .PARAMETER pfxPassword
        A securestring containing a single password that is common across all certificates
    .PARAMETER ExternalFQDN
        Specifies the Azure Stack's External FQDN, also aliased as ExternalFQDN and ExternalDomainName, must be valid DNSHostName. Does not need to be resolved.
    .PARAMETER DeviceName
        Specifies the Device Name of an Azure Stack Edge device.
    .PARAMETER NodeSerialNumber
        Specifies the node serial number(s) of an Azure Stack Edge device.
    .PARAMETER CleanReport
        Specifies whether to purge the existing report and start again with a clean report. Execution history and validation data is lost for all Readiness Checker validations.
    .PARAMETER OutputPath
        Specifies custom path to save Readiness JSON report and Verbose log file.
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$true,HelpMessage="Enter Path to Certificates Directory")]
        [ValidateScript( {Test-Path $_ -PathType Container})]
        [string]
        $certificatepath,

        [Parameter(Mandatory = $true, HelpMessage = "Enter Password for PFX Certificates as a secure string" )]
        [securestring]
        $pfxPassword,

        [Parameter(Mandatory=$true, HelpMessage="Enter Azure Stack External FQDN")]
        [Alias("ExternalDomainName", "FQDN")]
        [ValidateScript( {[System.Uri]::CheckHostName($_) -eq 'dns' <#FQDN must be valid DNSHostName#>})]
        [string]
        $ExternalFQDN,

        [Parameter(Mandatory=$true, HelpMessage="Enter the Device Name of an Azure Stack Edge device.")]
        [string]
        $DeviceName,

        [Parameter(Mandatory=$true, HelpMessage="Enter the Node Serial Number of an Azure Stack Edge device.")]
        [string[]]
        $NodeSerialNumber,

        [Parameter(HelpMessage = "Directory path for log and report output")]
        [string]$OutputPath = "$ENV:TEMP\AzsReadinessChecker",

        [Parameter(HelpMessage = "Remove all previous progress and create a clean report")]
        [switch]$CleanReport = $false
    )
    Invoke-AzsCertificateValidation @PSBoundParameters -CertificateType AzureStackEdgeDevice
}

function Invoke-AzsEdgeVPNCertificateValidation {
    <#
    .SYNOPSIS
        Run certificate validation for Azure Stack Edge VPN Certificates
    .DESCRIPTION
        Calls Invoke-AzsCertificateValidation with neccessary parameters to validate Azure Stack Edge VPN certificates
    .EXAMPLE
        $pfxPassword = Read-Host -Prompt "Enter PFX Password" -AsSecureString
        $certificateValidationParams = @{
            certificatePath = "$ENV:USERPROFILE\Documents\AzureStack\Certificates\AzureStackEdgeVPN"
            pfxPassword = $pfxPassword
            ExternalFQDN = "azurestackedge.contoso.com"
        }
        Invoke-AzsEdgeVPNCertificateValidation @certificateValidationParams
        Run certificate validation for Azure Stack Edge VPN Certificates
    .PARAMETER CertificatePath
        Path to directory structure for Azure Stack Edge VPN Certificates.
    .PARAMETER pfxPassword
        A securestring containing a single password that is common across all certificates
    .PARAMETER ExternalFQDN
        Specifies the Azure Stack's External FQDN, also aliased as ExternalFQDN and ExternalDomainName, must be valid DNSHostName. Does not need to be resolved.
    .PARAMETER CleanReport
        Specifies whether to purge the existing report and start again with a clean report. Execution history and validation data is lost for all Readiness Checker validations.
    .PARAMETER OutputPath
        Specifies custom path to save Readiness JSON report and Verbose log file.
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$true,HelpMessage="Enter Path to Certificates Directory")]
        [ValidateScript( {Test-Path $_ -PathType Container})]
        [string]
        $certificatepath,

        [Parameter(Mandatory = $true, HelpMessage = "Enter Password for PFX Certificates as a secure string" )]
        [securestring]
        $pfxPassword,

        [Parameter(Mandatory=$true, HelpMessage="Enter Azure Stack External FQDN")]
        [Alias("ExternalDomainName", "FQDN")]
        [ValidateScript( {[System.Uri]::CheckHostName($_) -eq 'dns' <#FQDN must be valid DNSHostName#>})]
        [string]
        $ExternalFQDN,

        [Parameter(HelpMessage = "Directory path for log and report output")]
        [string]
        $OutputPath = "$ENV:TEMP\AzsReadinessChecker",

        [Parameter(HelpMessage = "Remove all previous progress and create a clean report")]
        [switch]
        $CleanReport = $false
    )
    Invoke-AzsCertificateValidation @PSBoundParameters -CertificateType AzureStackEdgeVPN
}

function Invoke-AzsHubDeploymentCertificateValidation {
    <#
    .SYNOPSIS
        Run certificate validation for Azure Stack Hub Deployment/Infrastructure Certificates
    .DESCRIPTION
        Calls Invoke-AzsCertificateValidation with neccessary parameters to validate Azure Stack Hub Deployment certificates
    .EXAMPLE
        $pfxPassword = Read-Host -Prompt "Enter PFX Password" -AsSecureString
        $certificateValidationParams = @{
            certificatepath = "$ENV:USERPROFILE\Documents\AzureStack\Certificates\Deployment"
            pfxPassword = $pfxPassword
            RegionName = 'east'
            ExternalFQDN = 'azurestack.contoso.com'
            IdentitySystem = 'AAD'
        }
        Invoke-AzsHubDeploymentCertificateValidation @certificateValidationParams
        Run certificate validation for Azure Stack Hub Deployment/Infrastructure Certificates
    .EXAMPLE
        $pfxPassword = Read-Host -Prompt "Enter PFX Password" -AsSecureString
        $certificateValidationParams = @{
            certificatepath = "$ENV:USERPROFILE\Documents\AzureStack\Certificates\Deployment"
            pfxPassword = $pfxPassword
            DeploymentDataJSONPath = "$ENV:USERPROFILE\Documents\AzureStack\DeploymentData.json"
        }
        Invoke-AzsHubDeploymentCertificateValidation @certificateValidationParams
        Run certificate validation for Azure Stack Hub Deployment/Infrastructure Certificates using deploymentdata.json from deployment team.
    .PARAMETER CertificatePath
        Path to directory structure for Azure Stack Hub Deployment Certificates.
    .PARAMETER pfxPassword
        A securestring containing a single password that is common across all certificates
    .PARAMETER deploymentDataJSONPath
        Specifies the Azure Stack Hub deployment data JSON configuration file. This enables the deployment team and/or system integrators
        to validate directly against the deployment asset that seeds deployment. Replaces user input for region name, external FQDN and identity system (if applicable).
    .PARAMETER ExternalFQDN
        Specifies the Azure Stack deployment's External FQDN, also aliased as ExternalFQDN and ExternalDomainName, must be valid DNSHostName
    .PARAMETER RegionName
        Specifies the Azure Stack deployment's region name when deploymentdata.json is not used, must be alphanumeric.
     .PARAMETER IdentitySystem
        Specifies the Azure Stack deployment's Identity System valid values, AAD or ADFS, for Azure Active Directory and Active Directory Federated Services respectively
    .PARAMETER CleanReport
        Specifies whether to purge the existing report and start again with a clean report. Execution history and validation data is lost for all Readiness Checker validations.
    .PARAMETER OutputPath
        Specifies custom path to save Readiness JSON report and Verbose log file.
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$true, HelpMessage="Enter Path to Certificates Directory")]
        [ValidateScript( {Test-Path $_ -PathType Container})]
        [string]
        $certificatepath,

        [Parameter(Mandatory = $true, HelpMessage = "Enter Password for PFX Certificates as a secure string" )]
        [securestring]
        $pfxPassword,

        [Parameter(Mandatory=$true, ParameterSetName = "User", HelpMessage="Enter Azure Stack External FQDN")]
        [Alias("ExternalDomainName", "FQDN")]
        [ValidateScript( {[System.Uri]::CheckHostName($_) -eq 'dns' <#FQDN must be valid DNSHostName#>})]
        [string]
        $ExternalFQDN,

        [Parameter(Mandatory=$true, ParameterSetName = "User", HelpMessage="Enter Azure Stack Hub Region Name")]
        [ValidatePattern('(?# Region must be alphanumeric)^[a-zA-Z0-9]+$')]
        [string]
        $RegionName,

        [Parameter(Mandatory=$true, ParameterSetName = "User", HelpMessage="Enter Azure Stack Hub deployment identity system, AAD or ADFS.")]
        [ValidateSet('AAD', 'ADFS')]
        [string]
        $IdentitySystem,

        [Parameter(Mandatory = $true, ParameterSetName = "JSON", HelpMessage = "Enter Path to DeploymentData.json")]
        [ValidateScript( {Test-Path $_ -Include *.json})]
        [string]
        $deploymentDataJSONPath,

        [Parameter(HelpMessage = "Directory path for log and report output")]
        [string]
        $OutputPath = "$ENV:TEMP\AzsReadinessChecker",

        [Parameter(HelpMessage = "Remove all previous progress and create a clean report")]
        [switch]
        $CleanReport = $false
    )
    Invoke-AzsCertificateValidation @PSBoundParameters -CertificateType Deployment
}

function Invoke-AzsHubAppServicesCertificateValidation {
    <#
    .SYNOPSIS
        Run certificate validation for Azure Stack Hub AppServices Resource Provider Certificates
    .DESCRIPTION
        Calls Invoke-AzsCertificateValidation with neccessary parameters to validate Azure Stack Hub AppServices certificates
    .EXAMPLE
        $pfxPassword = Read-Host -Prompt "Enter PFX Password" -AsSecureString
        $certificateValidationParams = @{
            certificatepath = "$ENV:USERPROFILE\Documents\AzureStack\Certificates\AppServices"
            pfxPassword = $pfxPassword
            RegionName = 'east'
            ExternalFQDN = 'azurestack.contoso.com'
        }
        Invoke-AzsHubAppServicesCertificateValidation @certificateValidationParams
        Run certificate validation for Azure Stack Hub AppServices Resource Provider Certificates
    .EXAMPLE
        $pfxPassword = Read-Host -Prompt "Enter PFX Password" -AsSecureString
        $certificateValidationParams = @{
            certificatepath = "$ENV:USERPROFILE\Documents\AzureStack\Certificates\AppServices"
            pfxPassword = $pfxPassword
            DeploymentDataJSONPath = "$ENV:USERPROFILE\Documents\AzureStack\DeploymentData.json"
        }
        Invoke-AzsHubAppServicesCertificateValidation @certificateValidationParams
        Run certificate validation for Azure Stack Hub AppServices Resource Provider Certificates using deploymentdata.json from Deployment team.
    .PARAMETER CertificatePath
        Path to directory structure for Azure Stack Hub AppServices Certificates. Should contain sub folders named API, DefaultDomain, Identity and Publishing with
        appropriate certificates placed in each. Use New-AzsCertificateFolder -certificateType AppServices for help with generation.
    .PARAMETER pfxPassword
        A securestring containing a single password that is common across all certificates
    .PARAMETER ExternalFQDN
        Specifies the Azure Stack deployment's External FQDN, also aliased as ExternalFQDN and ExternalDomainName, must be valid DNSHostName
    .PARAMETER RegionName
        Specifies the Azure Stack deployment's region name, must be alphanumeric.
    .PARAMETER deploymentDataJSONPath
        Specifies the Azure Stack Hub deployment data JSON configuration file. This enables the deployment team and/or system integrators
        to validate directly against the deployment asset that seeds deployment. Replaces user input for region name, external FQDN and identity system (if applicable).
    .PARAMETER CleanReport
        Specifies whether to purge the existing report and start again with a clean report. Execution history and validation data is lost for all Readiness Checker validations.
    .PARAMETER OutputPath
        Specifies custom path to save Readiness JSON report and Verbose log file.
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$true, HelpMessage="Enter Path to Certificates Directory")]
        [ValidateScript( {Test-Path $_ -PathType Container})]
        [string]
        $certificatepath,

        [Parameter(Mandatory = $true, HelpMessage = "Enter Password for PFX Certificates as a secure string" )]
        [securestring]
        $pfxPassword,

        [Parameter(Mandatory=$true, ParameterSetName = "User", HelpMessage="Enter Azure Stack External FQDN")]
        [Alias("ExternalDomainName", "FQDN")]
        [ValidateScript( {[System.Uri]::CheckHostName($_) -eq 'dns' <#FQDN must be valid DNSHostName#>})]
        [string]
        $ExternalFQDN,

        [Parameter(Mandatory=$true, ParameterSetName = "User", HelpMessage="Enter Azure Stack Hub Region Name")]
        [ValidatePattern('(?# Region must be alphanumeric)^[a-zA-Z0-9]+$')]
        [string]
        $RegionName,

        [Parameter(Mandatory = $true, ParameterSetName = "JSON", HelpMessage = "Enter Path to DeploymentData.json")]
        [ValidateScript( {Test-Path $_ -Include *.json})]
        [string]
        $deploymentDataJSONPath,

        [Parameter(HelpMessage = "Directory path for log and report output")]
        [string]
        $OutputPath = "$ENV:TEMP\AzsReadinessChecker",

        [Parameter(HelpMessage = "Remove all previous progress and create a clean report")]
        [switch]
        $CleanReport = $false
    )
    Invoke-AzsCertificateValidation @PSBoundParameters -CertificateType AppServices
}

function Invoke-AzsHubEventHubsCertificateValidation {
    <#
    .SYNOPSIS
        Run certificate validation for Azure Stack Hub EventHubs Resource Provider Certificates
    .DESCRIPTION
        Calls Invoke-AzsCertificateValidation with neccessary parameters to validate Azure Stack Hub EventHubs certificates
    .EXAMPLE
        $pfxPassword = Read-Host -Prompt "Enter PFX Password" -AsSecureString
        $certificateValidationParams = @{
            certificatepath = "$ENV:USERPROFILE\Documents\AzureStack\Certificates\EventHubs"
            pfxPassword = $pfxPassword
            RegionName = 'east'
            ExternalFQDN = 'azurestack.contoso.com'
        }
        Invoke-AzsHubEventHubsCertificateValidation @certificateValidationParams
        Run certificate validation for Azure Stack Hub EventHubs Resource Provider Certificates
    .EXAMPLE
        $pfxPassword = Read-Host -Prompt "Enter PFX Password" -AsSecureString
        $certificateValidationParams = @{
            certificatepath = "$ENV:USERPROFILE\Documents\AzureStack\Certificates\EventHubs"
            pfxPassword = $pfxPassword
            DeploymentDataJSONPath = "$ENV:USERPROFILE\Documents\AzureStack\DeploymentData.json"
        }
        Invoke-AzsHubEventHubsCertificateValidation @certificateValidationParams
        Run certificate validation for Azure Stack Hub EventHubs Resource Provider Certificates with deploymentdata.json from Deployment team.
    .PARAMETER CertificatePath
        Path to directory structure for Azure Stack Hub EventHubs Certificates.
    .PARAMETER pfxPassword
        A securestring containing a single password that is common across all certificates
    .PARAMETER ExternalFQDN
        Specifies the Azure Stack deployment's External FQDN, also aliased as ExternalFQDN and ExternalDomainName, must be valid DNSHostName
    .PARAMETER RegionName
        Specifies the Azure Stack deployment's region name, must be alphanumeric.
    .PARAMETER deploymentDataJSONPath
        Specifies the Azure Stack Hub deployment data JSON configuration file. This enables the deployment team and/or system integrators
        to validate directly against the deployment asset that seeds deployment. Replaces user input for region name, external FQDN and identity system (if applicable).
    .PARAMETER CleanReport
        Specifies whether to purge the existing report and start again with a clean report. Execution history and validation data is lost for all Readiness Checker validations.
    .PARAMETER OutputPath
        Specifies custom path to save Readiness JSON report and Verbose log file.
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$true, HelpMessage="Enter Path to Certificates Directory")]
        [ValidateScript( {Test-Path $_ -PathType Container})]
        [string]
        $certificatepath,

        [Parameter(Mandatory = $true, HelpMessage = "Enter Password for PFX Certificates as a secure string" )]
        [securestring]
        $pfxPassword,

        [Parameter(Mandatory=$true, ParameterSetName = "User", HelpMessage="Enter Azure Stack External FQDN")]
        [Alias("ExternalDomainName", "FQDN")]
        [ValidateScript( {[System.Uri]::CheckHostName($_) -eq 'dns' <#FQDN must be valid DNSHostName#>})]
        [string]
        $ExternalFQDN,

        [Parameter(Mandatory=$true, ParameterSetName = "User", HelpMessage="Enter Azure Stack Hub Region Name")]
        [ValidatePattern('(?# Region must be alphanumeric)^[a-zA-Z0-9]+$')]
        [string]
        $RegionName,

        [Parameter(Mandatory = $true, ParameterSetName = "JSON", HelpMessage = "Enter Path to DeploymentData.json")]
        [ValidateScript( {Test-Path $_ -Include *.json})]
        [string]
        $deploymentDataJSONPath,

        [Parameter(HelpMessage = "Directory path for log and report output")]
        [string]
        $OutputPath = "$ENV:TEMP\AzsReadinessChecker",

        [Parameter(HelpMessage = "Remove all previous progress and create a clean report")]
        [switch]
        $CleanReport = $false
    )
    Invoke-AzsCertificateValidation @PSBoundParameters -CertificateType EventHubs
}

function Invoke-AzsHubIoTHubCertificateValidation {
    <#
    .SYNOPSIS
        Run certificate validation for Azure Stack Hub IoTHub Resource Provider Certificates
    .DESCRIPTION
        Calls Invoke-AzsCertificateValidation with neccessary parameters to validate Azure Stack Hub IoTHub certificates
    .EXAMPLE
        $pfxPassword = Read-Host -Prompt "Enter PFX Password" -AsSecureString
        $certificateValidationParams = @{
            certificatepath = "$ENV:USERPROFILE\Documents\AzureStack\Certificates\IoTHub"
            pfxPassword = $pfxPassword
            RegionName = 'east'
            ExternalFQDN = 'azurestack.contoso.com'
        }
        Invoke-AzsHubIoTHubCertificateValidation @certificateValidationParams
        Run certificate validation for Azure Stack Hub IoTHub Resource Provider Certificates
    .EXAMPLE
        $pfxPassword = Read-Host -Prompt "Enter PFX Password" -AsSecureString
        $certificateValidationParams = @{
            certificatepath = "$ENV:USERPROFILE\Documents\AzureStack\Certificates\IoTHub"
            pfxPassword = $pfxPassword
            DeploymentDataJSONPath = "$ENV:USERPROFILE\Documents\AzureStack\DeploymentData.json"
        }
        Invoke-AzsHubIoTHubCertificateValidation @certificateValidationParams
        Run certificate validation for Azure Stack Hub IoTHub Resource Provider Certificates using deploymentdata.json from Deployment team.
    .PARAMETER CertificatePath
        Path to directory structure for Azure Stack Hub IoTHub Certificates.
    .PARAMETER pfxPassword
        A securestring containing a single password that is common across all certificates
    .PARAMETER ExternalFQDN
        Specifies the Azure Stack deployment's External FQDN, also aliased as ExternalFQDN and ExternalDomainName, must be valid DNSHostName
    .PARAMETER RegionName
        Specifies the Azure Stack deployment's region name, must be alphanumeric.
    .PARAMETER deploymentDataJSONPath
        Specifies the Azure Stack Hub deployment data JSON configuration file. This enables the deployment team and/or system integrators
        to validate directly against the deployment asset that seeds deployment. Replaces user input for region name, external FQDN and identity system (if applicable).
    .PARAMETER CleanReport
        Specifies whether to purge the existing report and start again with a clean report. Execution history and validation data is lost for all Readiness Checker validations.
    .PARAMETER OutputPath
        Specifies custom path to save Readiness JSON report and Verbose log file.
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$true, HelpMessage="Enter Path to Certificates Directory")]
        [ValidateScript( {Test-Path $_ -PathType Container})]
        [string]
        $certificatepath,

        [Parameter(Mandatory = $true, HelpMessage = "Enter Password for PFX Certificates as a secure string" )]
        [securestring]
        $pfxPassword,

        [Parameter(Mandatory=$true, ParameterSetName = "User", HelpMessage="Enter Azure Stack External FQDN")]
        [Alias("ExternalDomainName", "FQDN")]
        [ValidateScript( {[System.Uri]::CheckHostName($_) -eq 'dns' <#FQDN must be valid DNSHostName#>})]
        [string]
        $ExternalFQDN,

        [Parameter(Mandatory=$true, ParameterSetName = "User", HelpMessage="Enter Azure Stack Hub Region Name")]
        [ValidatePattern('(?# Region must be alphanumeric)^[a-zA-Z0-9]+$')]
        [string]
        $RegionName,

        [Parameter(Mandatory = $true, ParameterSetName = "JSON", HelpMessage = "Enter Path to DeploymentData.json")]
        [ValidateScript( {Test-Path $_ -Include *.json})]
        [string]
        $deploymentDataJSONPath,

        [Parameter(HelpMessage = "Directory path for log and report output")]
        [string]
        $OutputPath = "$ENV:TEMP\AzsReadinessChecker",

        [Parameter(HelpMessage = "Remove all previous progress and create a clean report")]
        [switch]
        $CleanReport = $false
    )
    Invoke-AzsCertificateValidation @PSBoundParameters -CertificateType IoTHub
}

function Invoke-AzsHubDBAdapterCertificateValidation {
    <#
    .SYNOPSIS
        Run certificate validation for Azure Stack Hub DBAdapter Resource Provider Certificates
    .DESCRIPTION
        Calls Invoke-AzsCertificateValidation with neccessary parameters to validate Azure Stack Hub DBAdapter certificates
    .EXAMPLE
        $pfxPassword = Read-Host -Prompt "Enter PFX Password" -AsSecureString
        $certificateValidationParams = @{
            certificatepath = "$ENV:USERPROFILE\Documents\AzureStack\Certificates\DBAdapter"
            pfxPassword = $pfxPassword
            RegionName = 'east'
            ExternalFQDN = 'azurestack.contoso.com'
        }
        Invoke-AzsHubDBAdapterCertificateValidation @certificateValidationParams
        Run certificate validation for Azure Stack Hub DBAdapter Resource Provider Certificates
    .EXAMPLE
        $pfxPassword = Read-Host -Prompt "Enter PFX Password" -AsSecureString
        $certificateValidationParams = @{
            certificatepath = "$ENV:USERPROFILE\Documents\AzureStack\Certificates\DBAdapter"
            pfxPassword = $pfxPassword
            DeploymentDataJSONPath = "$ENV:USERPROFILE\Documents\AzureStack\DeploymentData.json"
        }
        Invoke-AzsHubDBAdapterCertificateValidation @certificateValidationParams
        Run certificate validation for Azure Stack Hub DBAdapter Resource Provider Certificates using deploymentdata.json from Deployment team.
    .PARAMETER CertificatePath
        Path to directory structure for Azure Stack Hub DBAdapter Certificates.
    .PARAMETER pfxPassword
        A securestring containing a single password that is common across all certificates
    .PARAMETER ExternalFQDN
        Specifies the Azure Stack deployment's External FQDN, also aliased as ExternalFQDN and ExternalDomainName, must be valid DNSHostName
    .PARAMETER RegionName
        Specifies the Azure Stack deployment's region name, must be alphanumeric.
    .PARAMETER deploymentDataJSONPath
        Specifies the Azure Stack Hub deployment data JSON configuration file. This enables the deployment team and/or system integrators
        to validate directly against the deployment asset that seeds deployment. Replaces user input for region name, external FQDN and identity system (if applicable).
    .PARAMETER CleanReport
        Specifies whether to purge the existing report and start again with a clean report. Execution history and validation data is lost for all Readiness Checker validations.
    .PARAMETER OutputPath
        Specifies custom path to save Readiness JSON report and Verbose log file.
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$true, HelpMessage="Enter Path to Certificates Directory")]
        [ValidateScript( {Test-Path $_ -PathType Container})]
        [string]
        $certificatepath,

        [Parameter(Mandatory = $true, HelpMessage = "Enter Password for PFX Certificates as a secure string" )]
        [securestring]
        $pfxPassword,

        [Parameter(Mandatory=$true, ParameterSetName = "User", HelpMessage="Enter Azure Stack External FQDN")]
        [Alias("ExternalDomainName", "FQDN")]
        [ValidateScript( {[System.Uri]::CheckHostName($_) -eq 'dns' <#FQDN must be valid DNSHostName#>})]
        [string]
        $ExternalFQDN,

        [Parameter(Mandatory=$true, ParameterSetName = "User", HelpMessage="Enter Azure Stack Hub Region Name")]
        [ValidatePattern('(?# Region must be alphanumeric)^[a-zA-Z0-9]+$')]
        [string]
        $RegionName,

        [Parameter(Mandatory = $true, ParameterSetName = "JSON", HelpMessage = "Enter Path to DeploymentData.json")]
        [ValidateScript( {Test-Path $_ -Include *.json})]
        [string]
        $deploymentDataJSONPath,

        [Parameter(HelpMessage = "Directory path for log and report output")]
        [string]
        $OutputPath = "$ENV:TEMP\AzsReadinessChecker",

        [Parameter(HelpMessage = "Remove all previous progress and create a clean report")]
        [switch]
        $CleanReport = $false
    )
    Invoke-AzsCertificateValidation @PSBoundParameters -CertificateType DBAdapter
}

function Invoke-AzsHubDataBoxEdgeCertificateValidation {
    <#
    .SYNOPSIS
        Run certificate validation for Azure Stack Hub Databox Edge Resource Provider Certificates
    .DESCRIPTION
        Calls Invoke-AzsCertificateValidation with neccessary parameters to validate Azure Stack Hub DBAdapter certificates
    .EXAMPLE
        $pfxPassword = Read-Host -Prompt "Enter PFX Password" -AsSecureString
        $certificateValidationParams = @{
            certificatepath = "$ENV:USERPROFILE\Documents\AzureStack\Certificates\DataboxEdge"
            pfxPassword = $pfxPassword
            RegionName = 'east'
            ExternalFQDN = 'azurestack.contoso.com'
        }
        Invoke-AzsHubDataBoxEdgeCertificateValidation @certificateValidationParams
        Run certificate validation for Azure Stack Hub Databox Edge Resource Provider Certificates
    .EXAMPLE
        $pfxPassword = Read-Host -Prompt "Enter PFX Password" -AsSecureString
        $certificateValidationParams = @{
            certificatepath = "$ENV:USERPROFILE\Documents\AzureStack\Certificates\DataboxEdge"
            pfxPassword = $pfxPassword
            DeploymentDataJSONPath = "$ENV:USERPROFILE\Documents\AzureStack\DeploymentData.json"
        }
        Invoke-AzsHubDataBoxEdgeCertificateValidation @certificateValidationParams
        Run certificate validation for Azure Stack Hub Databox Edge Resource Provider Certificates using deploymentdata.json from Deployment team.
    .PARAMETER CertificatePath
        Path to directory structure for Azure Stack Hub DBAdapter Certificates.
    .PARAMETER pfxPassword
        A securestring containing a single password that is common across all certificates
    .PARAMETER ExternalFQDN
        Specifies the Azure Stack deployment's External FQDN, also aliased as ExternalFQDN and ExternalDomainName, must be valid DNSHostName
    .PARAMETER RegionName
        Specifies the Azure Stack deployment's region name, must be alphanumeric.
    .PARAMETER deploymentDataJSONPath
        Specifies the Azure Stack Hub deployment data JSON configuration file. This enables the deployment team and/or system integrators
        to validate directly against the deployment asset that seeds deployment. Replaces user input for region name, external FQDN and identity system (if applicable).
    .PARAMETER CleanReport
        Specifies whether to purge the existing report and start again with a clean report. Execution history and validation data is lost for all Readiness Checker validations.
    .PARAMETER OutputPath
        Specifies custom path to save Readiness JSON report and Verbose log file.
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$true, HelpMessage="Enter Path to Certificates Directory")]
        [ValidateScript( {Test-Path $_ -PathType Container})]
        [string]
        $certificatepath,

        [Parameter(Mandatory = $true, HelpMessage = "Enter Password for PFX Certificates as a secure string" )]
        [securestring]
        $pfxPassword,

        [Parameter(Mandatory=$true, ParameterSetName = "User", HelpMessage="Enter Azure Stack External FQDN")]
        [Alias("ExternalDomainName", "FQDN")]
        [ValidateScript( {[System.Uri]::CheckHostName($_) -eq 'dns' <#FQDN must be valid DNSHostName#>})]
        [string]
        $ExternalFQDN,

        [Parameter(Mandatory=$true, ParameterSetName = "User", HelpMessage="Enter Azure Stack Hub Region Name")]
        [ValidatePattern('(?# Region must be alphanumeric)^[a-zA-Z0-9]+$')]
        [string]
        $RegionName,

        [Parameter(Mandatory = $true, ParameterSetName = "JSON", HelpMessage = "Enter Path to DeploymentData.json")]
        [ValidateScript( {Test-Path $_ -Include *.json})]
        [string]
        $deploymentDataJSONPath,

        [Parameter(HelpMessage = "Directory path for log and report output")]
        [string]
        $OutputPath = "$ENV:TEMP\AzsReadinessChecker",

        [Parameter(HelpMessage = "Remove all previous progress and create a clean report")]
        [switch]
        $CleanReport = $false
    )
    Invoke-AzsCertificateValidation @PSBoundParameters -CertificateType DataboxEdge
}

function Invoke-AzsHubAzureContainerRegistryCertificateValidation {
    <#
    .SYNOPSIS
        Run certificate validation for Azure Stack Hub Azure Container Registry Resource Provider Certificates
    .DESCRIPTION
        Calls Invoke-AzsCertificateValidation with neccessary parameters to validate Azure Stack Hub DBAdapter certificates
    .EXAMPLE
        $pfxPassword = Read-Host -Prompt "Enter PFX Password" -AsSecureString
        $certificateValidationParams = @{
            certificatepath = "$ENV:USERPROFILE\Documents\AzureStack\Certificates\ACR"
            pfxPassword = $pfxPassword
            RegionName = 'east'
            ExternalFQDN = 'azurestack.contoso.com'
        }
        Invoke-AzsHubAzureContainerRegistryCertificateValidation @certificateValidationParams
        Run certificate validation for Azure Stack Azure Container Registry Resource Provider Certificates
    .EXAMPLE
        $pfxPassword = Read-Host -Prompt "Enter PFX Password" -AsSecureString
        $certificateValidationParams = @{
            certificatepath = "$ENV:USERPROFILE\Documents\AzureStack\Certificates\ACR"
            pfxPassword = $pfxPassword
            DeploymentDataJSONPath = "$ENV:USERPROFILE\Documents\AzureStack\DeploymentData.json"
        }
        Invoke-AzsHubAzureContainerRegistryCertificateValidation @certificateValidationParams
        Run certificate validation for Azure Stack Hub Azure Container Registry Resource Provider Certificates using deploymentdata.json from Deployment team.
    .PARAMETER CertificatePath
        Path to directory structure for Azure Stack Hub Azure Container Registry (ACR) Certificates.
    .PARAMETER pfxPassword
        A securestring containing a single password that is common across all certificates
    .PARAMETER ExternalFQDN
        Specifies the Azure Stack deployment's External FQDN, also aliased as ExternalFQDN and ExternalDomainName, must be valid DNSHostName
    .PARAMETER RegionName
        Specifies the Azure Stack deployment's region name, must be alphanumeric.
    .PARAMETER deploymentDataJSONPath
        Specifies the Azure Stack Hub deployment data JSON configuration file. This enables the deployment team and/or system integrators
        to validate directly against the deployment asset that seeds deployment. Replaces user input for region name, external FQDN and identity system (if applicable).
    .PARAMETER CleanReport
        Specifies whether to purge the existing report and start again with a clean report. Execution history and validation data is lost for all Readiness Checker validations.
    .PARAMETER OutputPath
        Specifies custom path to save Readiness JSON report and Verbose log file.
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$true, HelpMessage="Enter Path to Certificates Directory")]
        [ValidateScript( {Test-Path $_ -PathType Container})]
        [string]
        $certificatepath,

        [Parameter(Mandatory = $true, HelpMessage = "Enter Password for PFX Certificates as a secure string" )]
        [securestring]
        $pfxPassword,

        [Parameter(Mandatory=$true, ParameterSetName = "User", HelpMessage="Enter Azure Stack External FQDN")]
        [Alias("ExternalDomainName", "FQDN")]
        [ValidateScript( {[System.Uri]::CheckHostName($_) -eq 'dns' <#FQDN must be valid DNSHostName#>})]
        [string]
        $ExternalFQDN,

        [Parameter(Mandatory=$true, ParameterSetName = "User", HelpMessage="Enter Azure Stack Hub Region Name")]
        [ValidatePattern('(?# Region must be alphanumeric)^[a-zA-Z0-9]+$')]
        [string]
        $RegionName,

        [Parameter(Mandatory = $true, ParameterSetName = "JSON", HelpMessage = "Enter Path to DeploymentData.json")]
        [ValidateScript( {Test-Path $_ -Include *.json})]
        [string]
        $deploymentDataJSONPath,

        [Parameter(HelpMessage = "Directory path for log and report output")]
        [string]
        $OutputPath = "$ENV:TEMP\AzsReadinessChecker",

        [Parameter(HelpMessage = "Remove all previous progress and create a clean report")]
        [switch]
        $CleanReport = $false
    )
    Invoke-AzsCertificateValidation @PSBoundParameters -CertificateType ACR
}

function Invoke-AzsCustomCertificateValidation {
    <#
    .SYNOPSIS
        Run certificate validation for Custom Certificates.
    .DESCRIPTION
        Calls Invoke-AzsCertificateValidation with neccessary parameters to validate custom certificates, by default attributes will be validated against Azure Stack standards.
    .EXAMPLE
        $pfxPassword = Read-Host -Prompt "Enter PFX Password" -AsSecureString
        $customCertConfig = @{
            'NWTradersRP' = @{
                    DNSName = @('*.nwtraders','admin.nwtraders')
                    KeyLength = 4096
                }
                'TailSpinRP' = @{
                    DNSName = @('*.tailspin')
                    HashAlgorithm = 'SHA386'
                }
            }
 
            $certificateValidationParams = @{
                CustomCertConfig = $customCertConfig
                certificatepath = "$ENV:USERPROFILE\Documents\AzureStack\Certificates\CustomRPs"
                pfxPassword = $pfxPassword
                ExternalFQDN = 'east.azurestack.contoso.com'
            }
            Invoke-AzsCustomCertificateValidation @certificateValidationParams
        Validates multiple Certificates. Each single certificates should be placed in a subfolder (of CertificatePath) named the same as the key in the custom hashtable e.g. NWTraderRP and TailSpinRP as in the example.
    .PARAMETER CertificatePath
        Path to directory structure for Azure Stack Hub DBAdapter Certificates.
    .PARAMETER pfxPassword
        A securestring containing a single password that is common across all certificates
    .PARAMETER ExternalFQDN
        Specifies the certificates External FQDN, also aliased as ExternalFQDN and ExternalDomainName, must be valid DNSHostName, optional parameter, DNSName can contain full fqdn, or prefix
    .PARAMETER CustomCertConfig
        Specifies the custom hashtable to check a certificate against.
    .PARAMETER CleanReport
        Specifies whether to purge the existing report and start again with a clean report. Execution history and validation data is lost for all Readiness Checker validations.
    .PARAMETER OutputPath
        Specifies custom path to save Readiness JSON report and Verbose log file.
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$true, HelpMessage="Enter Path to Certificates Directory")]
        [ValidateScript( {Test-Path $_ -PathType Container})]
        [string]
        $certificatepath,

        [Parameter(Mandatory = $true, HelpMessage = "Enter Password for PFX Certificates as a secure string" )]
        [securestring]
        $pfxPassword,

        [Parameter(Mandatory=$false, ParameterSetName = "User", HelpMessage="Enter External FQDN")]
        [Alias("ExternalDomainName", "FQDN")]
        [ValidateScript( {[System.Uri]::CheckHostName($_) -eq 'dns' <#FQDN must be valid DNSHostName#>})]
        [string]
        $ExternalFQDN,

        [Parameter(Mandatory=$true, HelpMessage="Enter custom hashtable to check a certificate against")]
        [hashtable]
        $customCertConfig,

        [Parameter(HelpMessage = "Directory path for log and report output")]
        [string]
        $OutputPath = "$ENV:TEMP\AzsReadinessChecker",

        [Parameter(HelpMessage = "Remove all previous progress and create a clean report")]
        [switch]
        $CleanReport = $false
    )
    Invoke-AzsCertificateValidation @PSBoundParameters -CertificateType Custom
}
# SIG # Begin signature block
# MIIjkQYJKoZIhvcNAQcCoIIjgjCCI34CAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCD5U2sXu6fIYhme
# sjdg9qGFDSjT+zhqJydHs8kD9ucQHaCCDYEwggX/MIID56ADAgECAhMzAAACUosz
# qviV8znbAAAAAAJSMA0GCSqGSIb3DQEBCwUAMH4xCzAJBgNVBAYTAlVTMRMwEQYD
# VQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNy
# b3NvZnQgQ29ycG9yYXRpb24xKDAmBgNVBAMTH01pY3Jvc29mdCBDb2RlIFNpZ25p
# bmcgUENBIDIwMTEwHhcNMjEwOTAyMTgzMjU5WhcNMjIwOTAxMTgzMjU5WjB0MQsw
# CQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9u
# ZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMR4wHAYDVQQDExVNaWNy
# b3NvZnQgQ29ycG9yYXRpb24wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB
# AQDQ5M+Ps/X7BNuv5B/0I6uoDwj0NJOo1KrVQqO7ggRXccklyTrWL4xMShjIou2I
# sbYnF67wXzVAq5Om4oe+LfzSDOzjcb6ms00gBo0OQaqwQ1BijyJ7NvDf80I1fW9O
# L76Kt0Wpc2zrGhzcHdb7upPrvxvSNNUvxK3sgw7YTt31410vpEp8yfBEl/hd8ZzA
# v47DCgJ5j1zm295s1RVZHNp6MoiQF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