Fix NullReferenceException in GetEnrollmentResult for null DCV email by bhillkeyfactor · Pull Request #9 · Keyfactor/cscglobal-caplugin · GitHub
Skip to content

Fix NullReferenceException in GetEnrollmentResult for null DCV email#9

Merged
indrora merged 2 commits into
release-1.1from
hotfix/dcv-email-null-key
Jun 30, 2026
Merged

Fix NullReferenceException in GetEnrollmentResult for null DCV email#9
indrora merged 2 commits into
release-1.1from
hotfix/dcv-email-null-key

Conversation

@bhillkeyfactor

@bhillkeyfactor bhillkeyfactor commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes an ArgumentNullException (Value cannot be null. Parameter 'key') thrown from RequestManager.GetEnrollmentResult on every CSC enrollment where CSC returns a DcvDetail with email=null (typical for EMAIL DCV orders that come back with actionNeeded=N, and for CNAME-only DCV).

The condition for adding DCV email entries to the cnames dictionary was inverted: when dcv.Email was null, the original code entered the branch and called cnames.Add(null, null), throwing immediately. The new condition skips null/empty values (matching the intent) and adds a ContainsKey guard symmetric to the existing CName branch above.

Test plan

  • Enroll a cert via the CSC plugin using EMAIL DCV — enrollment completes (no NRE)
  • Enroll a cert via the CSC plugin using CNAME DCV — CNAME details still surface in EnrollmentContext as before
  • Build passes on net6.0 / net8.0

bhillkeyfactor and others added 2 commits June 24, 2026 14:14
The condition for adding DCV email entries to the cnames dictionary was
inverted (string.IsNullOrEmpty instead of !string.IsNullOrEmpty), causing
cnames.Add(null, null) and an ArgumentNullException on every enrollment
where CSC returned a DcvDetail with email=null (typical for EMAIL DCV
orders that have actionNeeded=N, and for CNAME-only DCV).

Inverts the condition and adds a ContainsKey guard to mirror the existing
CName branch.
@bhillkeyfactor bhillkeyfactor requested review from indrora and mkachk and removed request for mkachk June 29, 2026 16:08
@indrora indrora merged commit 1564d81 into release-1.1 Jun 30, 2026
15 of 16 checks passed
indrora added a commit that referenced this pull request Jun 30, 2026
* Add custom field support

* changelog

* support cname return from enrollment

* Update generated docs

* feat: release 1.1.1

* Update generated docs

* Fix for issues with

* Test

* Added template parameter configuration via REST gateway. Fixed bug with email used for verification. Changed docs and enrollment field/template parameter names. See changelog.

* Update generated docs

* Fixed broken logging.

* Incremental sync support added using  csc date filter so sync timing can run faster that default full sync periods

* Update generated docs

* Fixes for Incremental Sync

* Update CHANGELOG.md

---------

Co-authored-by: Mikey Henderson <4452096+fiddlermikey@users.noreply.github.com>
Co-authored-by: Sean <1661003+spbsoluble@users.noreply.github.com>
Co-authored-by: Keyfactor <keyfactor@keyfactor.github.io>
Co-authored-by: Brian Hill <bhill@keyfactor.com>
Co-authored-by: Brian Hill <76450501+bhillkeyfactor@users.noreply.github.com>

* Fix NullReferenceException in GetEnrollmentResult for null DCV email (#9)

* Fix NullReferenceException in GetEnrollmentResult for null DCV email

The condition for adding DCV email entries to the cnames dictionary was
inverted (string.IsNullOrEmpty instead of !string.IsNullOrEmpty), causing
cnames.Add(null, null) and an ArgumentNullException on every enrollment
where CSC returned a DcvDetail with email=null (typical for EMAIL DCV
orders that have actionNeeded=N, and for CNAME-only DCV).

Inverts the condition and adds a ContainsKey guard to mirror the existing
CName branch.

* Update generated docs

---------

Co-authored-by: Keyfactor <keyfactor@keyfactor.github.io>

---------

Co-authored-by: David Galey <dgaley@keyfactor.com>
Co-authored-by: Keyfactor <keyfactor@keyfactor.github.io>
Co-authored-by: Mark Kachkaev <37276742+mkachk@users.noreply.github.com>
Co-authored-by: Mikey Henderson <4452096+fiddlermikey@users.noreply.github.com>
Co-authored-by: Sean <1661003+spbsoluble@users.noreply.github.com>
Co-authored-by: Brian Hill <bhill@keyfactor.com>
Co-authored-by: Brian Hill <76450501+bhillkeyfactor@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants