forums.win
#

WELCOME TO THE COMMUNITY

f/Java Certificates

Where curious people come to talk java certificates.

New members 12 online now
Create a post

GO DEEPER

Subcommunities

Create one

This community has room to grow.

Create the first subcommunity →

FRESH FROM F/JAVA CERTIFICATES

Latest posts

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