PSPKI icon indicating copy to clipboard operation
PSPKI copied to clipboard

Publish-CRL throws: An attempt was made to access an uninitialized object

Open c3rberus opened this issue 2 years ago • 2 comments

Using PSPKI 3.7.2, when trying to run Publish-CRL -CertificationAuthority XXXXIntermediateCAv2 I get the following error:

Exception calling "PublishCRL" with "2" argument(s): "An attempt was made to access an uninitialized object."
At C:\Program Files\WindowsPowerShell\Modules\PSPKI\3.7.2\Server\Publish-CRL.ps1:15 char:4
+             $CA.PublishCRL($DeltaOnly, $UpdateFile)
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : UninitializedObjectException

If I try this another method, I get this..

PS C:\Windows\system32> Get-CertificationAuthority | Publish-CRL
Exception calling "PublishCRL" with "2" argument(s): "CCertAdmin::PublishCRLs: The parameter is incorrect. 0x80070057
(WIN32: 87 ERROR_INVALID_PARAMETER)"
At C:\Program Files\WindowsPowerShell\Modules\PSPKI\3.7.2\Server\Publish-CRL.ps1:15 char:4
+             $CA.PublishCRL($DeltaOnly, $UpdateFile)
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentException

Any idea why this is happening?

c3rberus avatar Dec 01 '21 15:12 c3rberus

do you receive your CAs when calling Get-CertificationAuthority and are they online and accessible?

Crypt32 avatar Dec 01 '21 16:12 Crypt32

Same issue here, also on v3.7.2 Get-CertificationAuthority results in:

Name                 : <redacted>
DisplayName          : <redacted>
ComputerName         : <redacted>
ConfigString         : <redacted>
DistinguishedName    : CN=<redacted>,CN=Enrollment Services,CN=Public Key 
                       Services,CN=Services,CN=Configuration,<redacted>
Type                 : Enterprise Subordinate CA
IsEnterprise         : True
IsRoot               : False
OperatingSystem      : Microsoft Windows Server 2019 Datacenter
IsAccessible         : True
RegistryOnline       : True
ServiceStatus        : Running
SetupStatus          : ServerInstall, SecurityUpgraded, ServerIsUptoDate
Certificate          : [Subject]
                         <redacted>
                       
                       [Issuer]
                         <redacted>
                       
                       [Serial Number]
                         <redacted>
                       
                       [Not Before]
                         <redacted>
                       
                       [Not After]
                        <redacted>
                       
                       [Thumbprint]
                         <redacted>
                       
BaseCRL              : 
DeltaCRL             : 
EnrollmentServiceURI : 
EnrollmentEndpoints  : {}

Publish-CRL -CertificationAuthority $ca.Name gives the same error as OP. In my case this is a blank setup.

kempd avatar Feb 11 '22 11:02 kempd

Getting the same error as OP:

$CAName = 'My CA'
$CAObj = Get-CertificationAuthority -Name $CAName
$CAObj | Publish-CRL
Exception calling "PublishCRL" with "2" argument(s): "CCertAdmin::PublishCRLs: The parameter is incorrect. 0x80070057 (WIN32: 87 ERROR_INVALID_PARAMETER)"
At C:\Program Files\PKI Solutions\PowerShell Modules\PSPKI\Server\Publish-CRL.ps1:15 char:4
+             $CA.PublishCRL($DeltaOnly, $UpdateFile)
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentException

jimbju avatar Dec 28 '22 10:12 jimbju

@jimbju what returns your $CAObj variable?

Crypt32 avatar Dec 29 '22 15:12 Crypt32

@Crypt32 contents of $CAObj:

DisplayName             ComputerName              IsAccessible ServiceStatus Type                     
-----------                  ------------                       ------------ ------------- ----                     
My CA                       mycacomputername...      True         Running       Enterprise Subordinate CA
$CAObj.GetType()

IsPublic IsSerial Name                                     BaseType                                                                                                     
-------- -------- ----                                     --------                                                                                                     
True     False    CertificateAuthority                     System.Object 

jimbju avatar Jan 02 '23 16:01 jimbju

Fixed in v4.0.0

Crypt32 avatar Jun 15 '23 07:06 Crypt32