Install/OnPrem/Solr/Import-RootCert.ps1

Import-Module "$PSScriptRoot\..\..\..\Common\SSL\SSL-Module.psm1" -Force
$ErrorActionPreference = "Stop"

$clientCert = $global:Configuration.ssl.custom.clientCert
$serverCert = $global:Configuration.ssl.custom.serverCert
if (([string]::IsNullOrEmpty($clientCert)) -and ([string]::IsNullOrEmpty($serverCert))) {
    $password = $global:Configuration.ssl.auto.pfxPassword
    $rootCertName = BuildSolrRootCertName -Prefix $global:Configuration.prefix
    
    CleanCertStore -CertName $rootCertName -Store "LocalMachine"
    CleanCertStore -CertName $rootCertName -Store "CurrentUser"
    
    ImportCert -PfxName "SolrRootSSLCertificate_SAF.pfx" -Password $password -Root
}
else {
    Write-Warning "It seems that you are using custom SSL certificates. Skipping import..." 
    Start-Sleep -s 5
}