-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adds SSLCertificate commands * Get-SSLCertificate * Show-SSLCertificateUI * Test-SSLCertificate
- Loading branch information
Showing
17 changed files
with
609 additions
and
208 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Get-SSLCertificate | ||
|
||
Open an SSL connection to the given host and read the presented server certificate. | ||
|
||
## Parameters | ||
|
||
### Parameter Set 1 | ||
|
||
- `[String]` **ComputerName** _A hostname or Url of the server to retreive the certificate._ Mandatory | ||
- `[Int32]` **Port** _The port to connect to the remote server._ | ||
- `[String]` **OutSslStreamVariable** _Stores SslStream connetion details from the command in the specified variable._ | ||
|
||
## Examples | ||
|
||
### Example 1 | ||
|
||
Return the certificate for google.com. | ||
|
||
```powershell | ||
Get-SSLCertificate google.com | ||
Thumbprint Subject EnhancedKeyUsageList | ||
---------- ------- -------------------- | ||
9B97772CC2C860B0D0663AD3ED34272FF927EDEE CN=*.google.com Server Authentication | ||
``` | ||
### Example 2 | ||
|
||
Verify a server certificate. You can use Test-SSLCertificate to validate the entire certificate chain. | ||
|
||
```powershell | ||
$cert = Get-SSLCertificate expired.badssl.com | ||
$cert.Verify() | ||
False | ||
``` | ||
### Example 3 | ||
|
||
Write SslStream connection details to Verbose stream. | ||
|
||
```powershell | ||
$cert = Get-SSLCertificate google.com -verbose | ||
VERBOSE: Converting Uri to host string | ||
VERBOSE: ComputerName = google.com | ||
VERBOSE: Cipher: Aes256 strength 256 | ||
VERBOSE: Hash: Sha384 strength 0 | ||
VERBOSE: Key exchange: None strength 0 | ||
VERBOSE: Protocol: Tls13 | ||
``` | ||
### Example 4 | ||
|
||
Stores SslStream connection details in the `$sslStreamValue` variable. | ||
|
||
```powershell | ||
Get-SSLCertificate -ComputerName 'google.com' -OutSslStreamVariable sslStreamValue | ||
Thumbprint Subject EnhancedKeyUsageList | ||
---------- ------- -------------------- | ||
5D3AD94714B07830A1BFB445F6F581AD0AC77689 CN=*.google.com Server Authentication | ||
$sslStreamValue | ||
CipherAlgorithm : Aes256 | ||
CipherStrength : 256 | ||
HashAlgorithm : Sha384 | ||
HashStrength : 0 | ||
KeyExchangeAlgorithm : None | ||
KeyExchangeStrength : 0 | ||
SslProtocol : Tls13 | ||
``` | ||
|
||
## Links | ||
|
||
- [Invoke-HttpUnit](Invoke-HttpUnit.md) | ||
- [Test-SSLCertificate](Test-SSLCertificate.md) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
# httpunitPS | ||
|
||
|
||
A PowerShell port of httpunit. | ||
## Cmdlets | ||
|
||
## Commands | ||
|
||
- [Get-SSLCertificate](Get-SSLCertificate.md) _Get the SSL Certificate for given host._ | ||
- [Invoke-HttpUnit](Invoke-HttpUnit.md) _A PowerShell port of httpunit._ | ||
- [Show-SSLCertificateUI](Show-SSLCertificateUI.md) _Displays a dialog box with detailed information about the specified x509 certificate._ | ||
- [Test-SSLCertificate](Test-SSLCertificate.md) _Test the validitiy of a given certificate._ | ||
|
||
- [Invoke-HttpUnit](Invoke-HttpUnit.md) A PowerShell port of httpunit. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Show-SSLCertificateUI | ||
|
||
Displays a dialog box with detailed information about the specified x509 certificate. The dialog box includes buttons for installing or copying the certificate. | ||
|
||
## Parameters | ||
|
||
### Parameter Set 1 | ||
|
||
- `[X509Certificate2]` **Certificate** _An X509Certificate2 certificate object._ Mandatory, ValueFromPipeline | ||
|
||
### Parameter Set 2 | ||
|
||
- `[String]` **ComputerName** _A hostname or Url of the server to retreive the certificate to test._ Mandatory | ||
- `[Int32]` **Port** _The port to connect to the remote server._ | ||
|
||
## Examples | ||
|
||
### Example 1 | ||
|
||
Launches a certificate dialogue box with details about the google.com certificate. | ||
|
||
```powershell | ||
Get-SSLCertificate google.com | Show-SSLCertificateUI | ||
``` | ||
|
||
## Links | ||
|
||
- [Get-SSLCertificate](Get-SSLCertificate.md) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Test-SSLCertificate | ||
|
||
Verifies the entire certificates chain from a certificate object or hostname. | ||
|
||
## Parameters | ||
|
||
### Parameter Set 1 | ||
|
||
- `[X509Certificate2]` **Certificate** _An X509Certificate2 certificate object._ Mandatory, ValueFromPipeline | ||
- `[Switch]` **RevocationMode** _The Revocation Mode to use in validation. | ||
NoCheck: No revocation check is performed on the certificate. | ||
Offline: A revocation check is made using a cached certificate revocation list (CRL). | ||
Online: A revocation check is made using an online certificate revocation list (CRL)._ | ||
|
||
### Parameter Set 2 | ||
|
||
- `[Switch]` **RevocationMode** _The Revocation Mode to use in validation. | ||
NoCheck: No revocation check is performed on the certificate. | ||
Offline: A revocation check is made using a cached certificate revocation list (CRL). | ||
Online: A revocation check is made using an online certificate revocation list (CRL)._ | ||
- `[String]` **ComputerName** _A hostname or Url of the server to retreive the certificate to test._ Mandatory | ||
- `[Int32]` **Port** _The port to connect to the remote server._ | ||
|
||
## Examples | ||
|
||
### Example 1 | ||
|
||
Test the validity of the google SSL Certificate. | ||
|
||
```powershell | ||
Get-SSLCertificate google.com | Test-SSLCertificates | ||
True | ||
``` | ||
### Example 2 | ||
|
||
Tests an invalid certificates and inspect the error in variable `$validation` for the certificate details. | ||
|
||
```powershell | ||
Test-SSLCertificate expired.badssl.com -ErrorVariable validation | ||
Test-SSLCertificate: Certificate failed chain validation: | ||
A required certificate is not within its validity period when verifying against the current system clock or the timestamp in the signed file. | ||
False | ||
$validation.TargetObject.ChainElements.Certificate | ||
Thumbprint Subject EnhancedKeyUsageList | ||
---------- ------- -------------------- | ||
404BBD2F1F4CC2FDEEF13AABDD523EF61F1C71F3 CN=*.badssl.com, OU… {Server Authentication, Client Authentication} | ||
339CDD57CFD5B141169B615FF31428782D1DA639 CN=COMODO RSA Domai… {Server Authentication, Client Authentication} | ||
AFE5D244A8D1194230FF479FE2F897BBCD7A8CB4 CN=COMODO RSA Certi… | ||
``` | ||
|
||
## Links | ||
|
||
- [Get-SSLCertificate](Get-SSLCertificate.md) | ||
- [https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.x509certificates.x509chain?view=net-8.0#remarks](https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.x509certificates.x509chain?view=net-8.0#remarks) |
Oops, something went wrong.