Save this to a .ps1 file:
# https://blogs.infinitesquare.com/posts/windows/creer-un-certificat-auto-signe-pour-vos-packages-windows-uwp-de-longue-duree
# https://docs.microsoft.com/pt-br/windows/uwp/packaging/create-certificate-package-signing
$pass = Read-Host 'Password?' -AsSecureString
$duree = Read-Host 'Years to expire?'
$subject = Read-Host 'Certificate Subject?'
# Où se trouve t'on ?
$invocation = (Get-Variable MyInvocation).Value
$directorypath = Split-Path $invocation.MyCommand.Path
# on se place au niveau machine
Set-Location Cert:\LocalMachine\My
#un certificat du même sujet existe ?
$thumbprint =Get-ChildItem | Where-Object {$_.subject -match $subject} | Select-Object -first 1 | select -ExpandProperty Thumbprint
if($thumbprint -ne $null)
{
Write-Host "deleting old one "$thumbprint;
Remove-Item -Path $thumbprint;
}
# création d'un nouveau certificat
New-SelfSignedCertificate -NotAfter (Get-Date).AddYears(42) -TextExtension ('2.5.29.37={text}1.3.6.1.5.5.7.3.3','2.5.29.19={text}Subject Type:End Entity') -Type Custom -Subject $subject -KeyUsage DigitalSignature -FriendlyName "Certificat de signature de code" -CertStoreLocation "Cert:\LocalMachine\My"
# récupération du thumbprint du certifcat créé
$thumbprint = Get-ChildItem | Where-Object {$_.subject -match $subject} | Select-Object -first 1 | select -ExpandProperty Thumbprint;
#Export du PFX
Export-PfxCertificate -cert $thumbprint -Password $pass -FilePath $directorypath\MON_CERTIFICAT.pfx
Set-Location C:\temp\UWP
Nenhum comentário :
Postar um comentário