Install/OnPrem/Solr/Import-ServerCert.ps1

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

$serverCert = $global:Configuration.ssl.custom.serverCert
if ([string]::IsNullOrEmpty($serverCert)) {
    $password = $global:Configuration.ssl.auto.pfxPassword
    $certName = BuildSolrServerCertName -Prefix $global:Configuration.prefix
    
    CleanCertStore -CertName $certName -Store "LocalMachine"
    CleanCertStore -CertName $certName -Store "CurrentUser"
    
    ImportCert -PfxName "SolrServerSSLCertificate_SAF.pfx" -Password $password
}
else {
    Write-Warning "It seems that you are using a custom SSL server certificate. Skipping import..." 
    Start-Sleep -s 5
}