Skip to content

Commit

Permalink
Create Generate-SelfCertPfx.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
0x5bfa authored Aug 23, 2024
1 parent 2e83134 commit df31acf
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions scripts/Generate-SelfCertPfx.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright (c) 2024 Files Community
# Licensed under the MIT License. See the LICENSE.

# Abstract:
# This script generates a self-signed certificate for the temporary packaging as a pfx file.

param(
[string]$Destination = ""
)

$CertFriendlyName = "FilesApp_SelfSigned"
$CertPublisher = "CN=Files"
$CertStoreLocation = "Cert:\CurrentUser\My"

# Generate self signed cert
$cert = New-SelfSignedCertificate `
-Type Custom `
-Subject $CertPublisher `
-KeyUsage DigitalSignature `
-FriendlyName $CertFriendlyName `
-CertStoreLocation $CertStoreLocation `
-TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}")

# Get size of the self signed cert
$certificateBytes = $cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pkcs12)

# Save the self signed cert as a file
[System.IO.File]::WriteAllBytes($Destination, $certificateBytes)

0 comments on commit df31acf

Please sign in to comment.