Last active
January 25, 2024 18:24
-
-
Save jamesperrin/d599f778f11583f960f229553dfe1762 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################################## | |
# | |
# Purpose: To registry proxy SSL certificate with Fortify Java. | |
# OS: Windows | |
# Terminal: PowerShell | |
# | |
# James Perrin, @jamesperrin | https://github.com/jamesperrin | |
# Licensed under CC0-1.0 (https://creativecommons.org/publicdomain/zero/1.0/) | |
################################################################################## | |
################################################################################## | |
# Restrictions: Needs to be ran with elevated privileges | |
################################################################################## | |
#Requires -RunAsAdministrator | |
$validResponses = "y", "n" | |
$yesResponses = "y" | |
$exitResponses = "e" | |
Do { | |
Write-Host "====================================================" | |
Write-Host "" | |
Write-Host "Are you updating the Fortify Proxy Certificate?" | |
Write-Host "" | |
Write-Host "y: Yes" | |
Write-Host "n: No" | |
Write-Host "e: Exit" | |
Write-Host "" | |
$isUpdating = Read-Host -Prompt "Please choose an action? [y, n or e]" | |
if ($exitResponses -contains $isUpdating.ToLower() ) { | |
Write-Host "Exiting" | |
Exit | |
} | |
}While (-not($validResponses -contains $isUpdating.ToLower())) | |
# Download Root Certificate | |
# Uncomment if you have a location to download your company's Root Certificate | |
# Invoke-WebRequest https://URL/TO/ROOT/CERTIFICATE/Enterprirse-Root-Cert.cer -OutFile ./Enterprirse-Root-Cert.cer | |
# Sets the location of certificate | |
$RootCertificate= "$(Get-Location)\Enterprirse-Root-Cert.cer" | |
# Sets alias for the proxy SSL Certificate | |
$Alias="enterpriseproxy" | |
# Sets password for Java Keytool | |
$KeytoolPassword="changeit" | |
# Sets the path to the Fortify installation | |
# C:\Program Files\Fortify\Fortify_SCA_23.2.0\jre\bin | |
$FindFortifyPath = Get-ChildItem "C:\Program Files\Fortify\Fortify_SCA*" | Select-Object -Unique Name | |
$FortifyPath = "C:\Program Files\Fortify\$($FindFortifyPath.Name)\jre\bin" | |
# Sets the path to the Fortify Apps and Tools installation | |
# C:\Program Files\Fortify\Fortify_Apps_and_Tools_23.2.0\jre\bin | |
$FindFortifyAppPath = Get-ChildItem "C:\Program Files\Fortify\Fortify_Apps*" | Select-Object -Unique Name | |
$FortifyAppPath = "C:\Program Files\Fortify\$($FindFortifyAppPath.Name)\jre\bin" | |
# Delete old Proxy Certificate | |
if ($yesResponses -contains $isUpdating.ToLower()) { | |
Start-Process -NoNewWindow -FilePath "$($FortifyPath)\keytool.exe" -ArgumentList "-delete -cacerts -alias $($Alias) -v -noprompt -storepass ($KeytoolPassword)" | |
Start-Process -NoNewWindow -FilePath "$($FortifyAppPath)\keytool.exe" -ArgumentList "-delete -cacerts -alias $($Alias) -v -noprompt -storepass ($KeytoolPassword)" | |
} | |
# Add Proxy Certificate | |
Start-Process -NoNewWindow -FilePath "$($FortifyPath)\keytool.exe" -ArgumentList "-import -v -cacerts -alias $($Alias) -file $($RootCertificate) -noprompt -storepass $($KeytoolPassword)" | |
Start-Process -NoNewWindow -FilePath "$($FortifyAppPath)\keytool.exe" -ArgumentList "-import -v -cacerts -alias $($Alias) -file $($RootCertificate) -noprompt -storepass $($KeytoolPassword)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment