powershell - Get Public Key from CSR -
can please me following question (using powershell)
i have csr in base64 string saved variable called $csr
i want public key csr, reason want want check public key (and therefore private key) not being reused when submitting csr microsoft ca. idea copy of cert same subject name (if 1 exists) ca , check public key again csr.
so need public key csr mentioned, far have done following
$requestx = new-object comobjectx509enrollment.cx509certificaterequestpkcs10
$requestx.initializedecode($csr,6) `$requestx.publickey
rather public key being returned com object. have use reflection on com object extract public key? there easier way? (i use certutil , bit of regex rather not)
thanks e brant
i figured out messing etc....
so goal compare public key in csr public key in existing certificate see if match of not (now may easier way, got it)
$csr = @" <csr here in base64> "@ $objxx = [system.security.cryptography.x509certificates.x509certificate2]::createfromcertfile("c:\csr\cert-testsite.cer") $x = [system.convert]::tobase64string($objxx.getpublickey()) $requestx = new-object -comobject x509enrollment.cx509certificaterequestpkcs10 $requestx.initializedecode($csr,6) $y = $requestx.publickey.encodedkey() -replace "`r`n" compare-object $x $y
Comments
Post a Comment