Ich habe ein PFX-Zertifikat mit der Visual Studio Developer-Eingabeaufforderung wie folgt erstellt.
makecert -r -pe -n "CN=mycert" -sky exchange "mycert.cer" -sv "mycert.pvk"
pvk2pfx -pvk "mycert.pvk" -spc "mycert.cer" -pfx "mycert.pfx" -pi [password]
Dann benutze ich PowerShell, um das Zertifikat abzufragen
$cert = Get-PfxCertificate [Location]
$cert.Verify()
# Returns 'False'
Wie kann ich dieses Zertifikat für die Verschlüsselung verwenden?
Aktualisieren
@ root vorgeschlagen mit Import-PfxCertificate Befehl. Dies ist, was passiert, wenn ich es laufen lasse.
Import-PfxCertificate -FilePath [Path]
Import-PfxCertificate : The PFX file you are trying to import requires either a different password or membership in an Active Directory principal to which it is protected.
At line:1 char:1
+ Import-PfxCertificate -FilePath [...]
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Import-PfxCertificate], Win32Exception
+ FullyQualifiedErrorId : System.ComponentModel.Win32Exception,Microsoft.CertificateServices.Commands.Im
portPfxCertificate
Weiteres Update
@ McDonald's schlug eine sichere Methode vor, um das Passwort an das zu übergeben Import-PfxCertificate Befehl. Das habe ich versucht;
Import-PfxCertificate -FilePath [Path] -Password (Get-Credential).Password
$cert = dir cert:\localmachine\my | where { $_.Thumbprint -eq [Thumbprint] } | Select-Object
$cert.Verify()
Gibt immer noch false zurück. Noch mehr Hinweise?
$cert.Verify() gibt false zurück. Aufgrund dieses neuen Fehlers denke ich jedoch nicht, dass dies tatsächlich mein Problem ist. Vielmehr ist das Zertifikat falsch konfiguriert. Meine Frage ist, warum das Zertifikat falsch konfiguriert ist.
Import-PfxCertificate –FilePath C:\mycert.cer cert:\localMachine\my -Password (ConvertTo-SecureString -String "[Password]" -Force –AsPlainText).... technet.microsoft.com/en-us/itpro/powershell/windows/pkiclient/…