Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xCertReq failed with error #42

Closed
svenvanrijen opened this issue Jan 21, 2017 · 10 comments
Closed

xCertReq failed with error #42

svenvanrijen opened this issue Jan 21, 2017 · 10 comments
Assignees
Labels
bug The issue is a bug.

Comments

@svenvanrijen
Copy link
Contributor

Please see error below:

PowerShell DSC resource MSFT_xCertReq failed to execute Set-TargetResource functionality with error message: The process 'C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe' with arguments '-Command "& C:\Windows\system32\certreq.exe @('-submit','-q','-config','CA01.xxxx.xxx\xxxxxx-CA01-CA','C:\Windows\TEMP\xCertReq-b6e74f80-5f35-46b2-a477-24098ca9b417.req','C:\Windows\TEMP\xCertReq-b6e74f80-5f35-46b2-a477-24098ca9b417.cer') | Set-Content -Path 'C:\Windows\TEMP\xCertReq-b6e74f80-5f35-46b2-a477-24098ca9b417.out'"' failed to start within the specified timeout.

Certificate is succesfully created but not put in to the right cert store, certificate stays in C:\Windows\Temp directory.

@PlagueHO PlagueHO self-assigned this Jan 21, 2017
@PlagueHO PlagueHO added bug The issue is a bug. in progress The issue is being actively worked on by someone. labels Jan 21, 2017
@PlagueHO
Copy link
Member

Hi @svenvanrijen - thanks for reporting this. I actually ran across this issue last week on one my servers. So I was going to log this, but you beat me to it. Great work. Are you able to post your config for me (blank out any credentials or other sensitive info of course)?

@svenvanrijen
Copy link
Contributor Author

Hi Daniel, no problem:

configuration Config            
{
  Import-DscResource -ModuleName xActiveDirectory, `
                                 xNetworking, `
                                 xPendingReboot, `
                                 xDHCPServer, `
                                 PSDesiredStateConfiguration, `
                                 xComputerManagement, `
                                 xAdcsDeployment, `
                                 xCertificate

  [pscredential]$domainCred = Get-AutomationPSCredential -Name 'Local domain admin'
    
  
  Node $AllNodes.Where{$_.Role -eq "DSC HTTPS Pull Server"}.Nodename
 
  {             
            
    LocalConfigurationManager            
    {            
            ActionAfterReboot = 'ContinueConfiguration'            
            ConfigurationMode = 'ApplyAndAutoCorrect'            
            RebootNodeIfNeeded = $true
    }    
  
    xComputer JoinDomain
    {
            Name          = $Node.NodeName
            DomainName    = $Node.DomainName
            Credential    = $domainCred
        }

    xCertReq SSLCert
    {
            CARootName                = 'xxxxxxx-CA01-CA'
            CAServerFQDN              = "CA01.xxxxxx.xxx"
            Subject                   = "xxxxxx.xxx"
            Exportable                = $true
            CertificateTemplate       = 'WebServer'
            AutoRenew                 = $true
            Credential                = $domainCred
        }        
      }   
    }

$ConfigData = @{             
    AllNodes = @(             
        @{             
            Nodename = "*"             
            DomainName = "xxxxx.xxx"             
            RetryCount = 20              
            RetryIntervalSec = 30            
            PsDscAllowPlainTextPassword = $true            
        }

        @{             
            Nodename = "xxxx"
            Role = "DSC HTTPS Pull Server"             
            DomainName = "xxxxxxx.xxx"             
            RetryCount = 20              
            RetryIntervalSec = 30            
            PsDscAllowPlainTextPassword = $true
            PsDscAllowDomainUser = $true            
        }
   )             
}                   

It's quite a large config, so I just cut and paste the bits for the node that matters. If you need any more info or details, please let me know...

Kind regards,
Sven

@svenvanrijen
Copy link
Contributor Author

Hi!
I've tried to troubleshoot this issue myself this, but unfortunately without any luck.
Guess it has something to do with creating and starting the Win32_Process within the PDT script... When I try this manually, I get an error regarding insufficient rights to start the process.

Anyway, I've got around it by changing my config to not use the $credential parameter and fixing an error in the xCertReq resource (https://github.com/PowerShell/xCertificate/pull/43/files). For now, my config runs smoothly, but the error mentioned above still exists.

xCertReq SSLCert
        {
            CARootName                = 'xxxxxxxxx-CA01-CA'
            CAServerFQDN              = 'xxxxx.xxxxx.xxxx'
            Subject                   = 'dsc01.xxxxx.xxxx'
            KeyLength                 = '1024'
            Exportable                = $true
            ProviderName              = '"Microsoft RSA SChannel Cryptographic Provider"'
            OID                       = '1.3.6.1.5.5.7.3.1'
            KeyUsage                  = '0xa0'
            CertificateTemplate       = 'WebServer'
            AutoRenew                 = $true
        } 

Kind regards,
Sven

@PlagueHO
Copy link
Member

PlagueHO commented Feb 2, 2017

Hi @svenvanrijen - thanks for the additional info! I'm definitely trying to get to this one. It is right up high on my list.

@rikhepworth
Copy link

Hi
I have encountered this exact issue. As with @svenvanrijen removing the $credential, and modifying the xCertReq resource with Sven's code change works. My configuration is pretty much identical to the one Sven is attempting to apply. I'm doing this on Windows Server 2012R2 with all current patches applied.

@PlagueHO
Copy link
Member

Hi @rikhepworth and @svenvanrijen - this does look like the solution to the problem. However the $credential is only required if the template requires an alternate credential to issue - so I don't think you'll need it mostly.

But because there is very little automated integration tests for this resource, I want to be certain that we're not making a breaking change. I've tried to implement some integration test for this resource (https://github.com/PowerShell/xCertificate/blob/dev/Tests/Integration/MSFT_xCertReq.Integration.Tests.ps1), so I'm just going to run these through on my CA's with the changes @svenvanrijen has made. I'm just doing this now and I'll get back to you ASAP.

Thanks again for your help and patience!

@PlagueHO
Copy link
Member

@rikhepworth and @svenvanrijen - there is still some sort of issue going on when the $credential parameter is being passed. So even once @svenvanrijen has been merged I'll still keep this issue open till I can figure out what is causing this problem.

@svenvanrijen
Copy link
Contributor Author

Successfully created PR #52

@PlagueHO
Copy link
Member

Hi @svenvanrijen - are we able to make this one as closed now?

@svenvanrijen
Copy link
Contributor Author

Yes, we can!
Issue successfully fixed in PR #52

@PlagueHO PlagueHO removed the in progress The issue is being actively worked on by someone. label Jun 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants