Update pfSenseCertViewer.ps1

This commit is contained in:
Alvaro Sedano 2019-09-13 19:51:18 +02:00 committed by GitHub
parent 4b79e997ba
commit f56538941d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,10 +2,12 @@
### pfSense Certificate Viewer (without private key) ### pfSense Certificate Viewer (without private key)
### Version 1.0.6 ### Version 1.0.6
#### ####
# Redefine the $cfg string variable to point to a valid unecrypted pfSense Configuration XML file. # Redefine the $cfg string variable to point to a valid pfSense Configuration XML file.
# You can also use the command line FilePath parameter as path to the input XML cfg file # You can also use the command line FilePath parameter as path to the input XML cfg file.
#
# This script will return the CA certificates, Server certificates, User certificates (used or not) and duplicated Serial Number Certificates # This script will return the CA certificates, Server certificates, User certificates (used or not)
# and duplicated Serial Number Certificates. If as result of errors generating serialnumber certificates,
# duplicated serialnumber certs (from the same CA) will be reported.
# #
# Tested on PowerShell 5.0 and avobe # Tested on PowerShell 5.0 and avobe
# Created by Alvaro Sedano Galindo. al_sedano@hotmail.com # Created by Alvaro Sedano Galindo. al_sedano@hotmail.com
@ -20,15 +22,14 @@
[Alias("File")] [Alias("File")]
[string]$FilePath) [string]$FilePath)
Function Get-BeginEndWO { Function Get-BeginEndWO {
Param([Parameter(Mandatory=$true, Position=0)][string]$path ` Param([Parameter(Mandatory=$true, Position=0)][string]$path `
,[Parameter(Mandatory=$true, Position=1)][ref]$osslDec) ,[Parameter(Mandatory=$true, Position=1)][ref]$osslDec)
#OPNsense saves on the xml encrypted file information about how to decrypt it. #OPNsense saves information on how to decrypt it in the xml encrypted file.
#pfSense does'nt. #pfSense does'nt.
#First line is #0 #First line is #0.
#Check if "^Version: OPNsense" exists in #line 1 #Check if "^Version: OPNsense" exists in #line 1
[string[]]$text = Get-Content $path -Encoding UTF8 [string[]]$text = Get-Content $path -Encoding UTF8
if ($text[1] -match '^Version: OPNsense') { if ($text[1] -match '^Version: OPNsense') {
@ -117,7 +118,7 @@ Function Decrypt {
[string]$rutaREG = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\OpenVPN" [string]$rutaREG = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\OpenVPN"
if (-not (Test-Path($rutaREG))) { if (-not (Test-Path($rutaREG))) {
Write-Host 'No openvpn installation found. openssl.exe is part of the openVPN installation. ' + ` Write-Host 'No openvpn installation found. openssl.exe is part of the openVPN installation. ' + `
'If you have another openssl.exe available path, you can redefine the $openSSL variable at line 114.' -BackgroundColor DarkRed 'If you have another openssl.exe available path, you can redefine the $openSSL variable at line 115.' -BackgroundColor DarkRed
Exit 3 Exit 3
} }