forums.win

LIVE FROM THE COMMUNITIES

Fresh conversations, right now.

The newest posts across forums.win, shown in the order they arrived.

LIVE FEED

The internet is talking.

New threads appear here as communities post them.
30recent posts
Newest firstAcross all communities
1

powershell script to apply Java Certificate to all Tomcat application

<#
PowerShell Script

  • Detects JDK/JRE path used by Tomcat (Procrun registry)
  • Locates cacerts under JavaHome\lib\security
  • Imports a trusted certificate

#>

param(
[string]$TomcatServiceName = "tomcat-115-38080",
[string]$CertFile = "D:\support\lvdxprdws11.lockheedfcu.download.crt",
[string]$Alias = "MyTrustedCA",
[string]$CacertsPassword = "changeit"
)

Write-Host "=== Checking Procrun Java registry path ==="

Your registry path format

$javaRegPath = "HKLM:\SOFTWARE\WOW6432Node\Apache Software Foundation\Procrun 2.0\$TomcatServiceName\Parameters\Java"

if (-not (Test-Path $javaRegPath)) {
throw "Registry path not found: $javaRegPath"
}

$javaParams = Get-ItemProperty -Path $javaRegPath

Use 'jvm' instead of JavaHome

$jvmPath = $javaParams.jvm

if (-not $jvmPath) {
throw "jvm key not found in registry: $javaRegPath"
}

Write-Host "Detected JVM DLL: $jvmPath"

Extract JavaHome from jvm.dll path

Example:

D:\Java\OpenJDK11.0.14\bin\server\jvm.dll

JavaHome = D:\Java\OpenJDK11.0.14

$javaHome = Split-Path (Split-Path (Split-Path $jvmPath))

Write-Host "Derived JavaHome: $javaHome"

Build cacerts path

$cacertsPath = Join-Path $javaHome "lib\security\cacerts"

if (-not (Test-Path $cacertsPath)) {
throw "cacerts not found at: $cacertsPath"
}

Write-Host "cacerts located at: $cacertsPath"

Locate keytool

$keytool = Join-Path $javaHome "bin\keytool.exe"

if (-not (Test-Path $keytool)) {
throw "keytool.exe not found at: $keytool"
}

Write-Host "=== Importing certificate into cacerts ==="
Write-Host "Certificate: $CertFile"
Write-Host "Alias: $Alias"

& $keytool -importcert -noprompt `
-alias $Alias `
-file $CertFile `
-keystore $cacertsPath `
-storepass $CacertsPassword

Write-Host "=== Certificate successfully imported ==="

0 comments

You’re all caught up.

Check back soon—the next great conversation is probably being typed right now.

Explore communities →