-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 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
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) |