Skip to content

Commit

Permalink
simplified fix for #9
Browse files Browse the repository at this point in the history
  • Loading branch information
rmbolger committed May 6, 2018
1 parent 619ff64 commit 013894c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
14 changes: 3 additions & 11 deletions Posh-ACME/Public/New-PACertificate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function New-PACertificate {
$SANs = @($Domain | Where-Object { $_ -ne $Domain[0] }) | Sort-Object
if ($Force -or !$order -or
$order.status -eq 'invalid' -or
($order.status -eq 'valid' -and (Get-Date) -ge (Get-Date $order.RenewAfter)) -or
($order.status -eq 'valid' -and $order.RenewAfter -and (Get-Date) -ge (Get-Date $order.RenewAfter)) -or
($order.status -eq 'pending' -and (Get-Date) -gt (Get-Date $order.expires)) -or
$CertKeyLength -ne $order.KeyLength -or
($SANs -join ',') -ne (($order.SANs | Sort-Object) -join ',') ) {
Expand Down Expand Up @@ -106,7 +106,7 @@ function New-PACertificate {
# The order should now be finalized and the status should be valid. The only
# thing left to do is download the cert and chain and write the results to
# disk
if ($order.status -eq 'valid' -and !$order.Complete) {
if ($order.status -eq 'valid' -and !$order.CertExpires) {
if ([string]::IsNullOrWhiteSpace($order.certificate)) {
throw "Order status is valid, but no certificate URL was found."
}
Expand All @@ -133,17 +133,9 @@ function New-PACertificate {
Write-Verbose "Successfully created certificate."
Write-Host "Certificate files saved to $($script:OrderFolder)"

# since there's no easy way to tell that we've already downloaded the finalized cert
# we'll add our own boolean to the order object to keep track
if ('Complete' -notin $order.PSObject.Properties.Name) {
$script:Order | Add-Member -MemberType NoteProperty -Name 'Complete' -Value $true
} else {
$script:Order.Complete = $true
}

Update-PAOrder -SaveOnly

} elseif ($order.Complete) {
} elseif ($order.CertExpires) {
Write-Verbose "This order has already been completed."
}

Expand Down
1 change: 0 additions & 1 deletion Posh-ACME/Public/New-PAOrder.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ function New-PAOrder {
$order | Add-Member -MemberType NoteProperty -Name 'DnsAlias' -Value $null
$order | Add-Member -MemberType NoteProperty -Name 'DnsSleep' -Value $null
$order | Add-Member -MemberType NoteProperty -Name 'ValidationTimeout' -Value $null
$order | Add-Member -MemberType NoteProperty -Name 'Complete' -Value $false

# make sure there's a certificate field for later
if ('certificate' -notin $order.PSObject.Properties.Name) {
Expand Down

0 comments on commit 013894c

Please sign in to comment.