Quantcast
Channel: Public Key Infrastructure PowerShell module
Viewing all articles
Browse latest Browse all 729

Commented Unassigned: Get-CertificateRevocationList fails when given a relative path to a CRL file [90]

$
0
0
If I try and retrieve a CRL from a local file using a relative path, the Cmdlet throws an exception:
```
PS Scripts:\> Get-CRL .\Temp.crl
New-Object : Exception calling ".ctor" with "1" argument(s): "The system cannot find the file specified"
At Z:\Documents\WindowsPowerShell\Modules\PSPKI\Client\Get-CertificateRevocationList.ps1:23 char:4
+ New-Object Security.Cryptography.X509Certificates.X509CRL2 -ArgumentList $Pat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
```

The full path to the same file works fine:
```
PS Scripts:\> Get-CRL Z:\Documents\Scripts\Temp.crl


Version : 2
Type : Base CRL
IssuerDN : System.Security.Cryptography.X509Certificates.X500DistinguishedName
Issuer : CN=...
ThisUpdate : 20/11/2015 14:42:02
NextUpdate : 21/01/2016 03:02:02
SignatureAlgorithm : System.Security.Cryptography.Oid
Extensions : {System.Security.Cryptography.Oid, System.Security.Cryptography.Oid,
System.Security.Cryptography.Oid, System.Security.Cryptography.Oid...}
RevokedCertificates :
RawData : {48, 130, 2, 137...}
Handle : 483681408
```

UPDATE:
A relative path from the root of the local drive works:
```
PS Z:\> Get-CRL .\Documents\Scripts\Temp.crl


Version : 2
Type : Base CRL
IssuerDN : System.Security.Cryptography.X509Certificates.X500DistinguishedName
Issuer : CN=...
ThisUpdate : 20/11/2015 14:42:02
NextUpdate : 21/01/2016 03:02:02
SignatureAlgorithm : System.Security.Cryptography.Oid
Extensions : {System.Security.Cryptography.Oid, System.Security.Cryptography.Oid,
System.Security.Cryptography.Oid, System.Security.Cryptography.Oid...}
RevokedCertificates :
RawData : {48, 130, 2, 137...}
Handle : 483680112
```

But not from a sub-folder:
```
PS Z:\Documents> Get-CRL .\Scripts\Temp.crl
New-Object : Exception calling ".ctor" with "1" argument(s): "The system cannot find the file specified"
At Z:\Documents\WindowsPowerShell\Modules\PSPKI\Client\Get-CertificateRevocationList.ps1:23 char:4
+ New-Object Security.Cryptography.X509Certificates.X509CRL2 -ArgumentList $Pat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
```
Comments: This issue is not related to PSPKI, it is related to PowerShell and .NET .NET may have different working directory (or directory base) than PowerShell, this is why the command fails. ``` PowerShell [io.directory]::GetCurrentDirectory() ``` this command returns current directory for .NET assemblies.

Viewing all articles
Browse latest Browse all 729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>