Update pfSenseCertViewer.ps1

This commit is contained in:
Alvaro Sedano 2019-09-11 02:26:11 +02:00 committed by GitHub
parent 266096089c
commit 1e4a925464
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,13 +1,13 @@
#### ####
### Extracting pfSense Certificates (without private key) ### pfSense Certificate Viewer (without private key)
### Version 1.0.3
#### ####
# Redefine the $cfg string variable to point to a valid non encrypted pfSense XML configuration backup file. # Redefine the $cfg string variable to point to a valid non encrypted pfSense XML configuration backup file.
# You can also pass the command line FilePath parameter as path to the input XML cfg file. # You can also pass the command line FilePath parameter as path to the input XML cfg file.
# The script will return the CA certificates, Server certificates, User certificates (used or not used) and # This script will return the CA certificates, Server certificates, User certificates (used or not) and duplicated Serial Number Certificates
# duplicated Serial Number Certificates.
# #
# Tested on PowerShell 5 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
# #
@ -21,7 +21,6 @@
[string]$FilePath) [string]$FilePath)
Function Get-CN { Function Get-CN {
Param([Parameter(Mandatory=$true)][string]$name) Param([Parameter(Mandatory=$true)][string]$name)
if($name -match "CN=([^,]*)") { if($name -match "CN=([^,]*)") {
@ -62,7 +61,6 @@ Function Add-Lista {
} }
} }
# #
# BODY # BODY
# #
@ -82,8 +80,8 @@ if (-not (Test-Path -Path $cfg)) {
Exit 1 Exit 1
} }
#Read XML pfSense config file #Read XML pfSense config file (UTF8 enconding)
[xml]$fxml = Get-Content $cfg -Encoding Default [xml]$fxml = Get-Content $cfg -Encoding UTF8
#Get the CRL revocation list #Get the CRL revocation list
[DateTime]$time0 = '1970-01-01' [DateTime]$time0 = '1970-01-01'
@ -98,7 +96,7 @@ Add-Lista -lista ([ref]$listaC) -obj ([ref]$fxml.pfsense.ca) -fromCA $true
#Add user/server certificates to $listaC (WITHOUT private keys) #Add user/server certificates to $listaC (WITHOUT private keys)
Add-Lista -lista ([ref]$listaC) -obj ([ref]$fxml.pfsense.cert) -fromCA $false Add-Lista -lista ([ref]$listaC) -obj ([ref]$fxml.pfsense.cert) -fromCA $false
#Note: User Certificates created with old pfSense versions can set the EnhancedKeyUsageList property to <empty> #Note: User Certificates created with old pfSense versions could set the EnhancedKeyUsageList property to <empty>.
Remove-Variable fxml, r Remove-Variable fxml, r