Conversation
… and password generator.
…e password. Useful when authenticating request against issued passwords cache
…ses <seealso> on top for some reasons.
…mbers are now obsolete.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds base implementation for custom NDES policy module implementation using .NET.
Overview
AD CS NDES service provides default NDES behavior customization such as:
The following article describes NDES components, their relationships and NDES transaction flow: Use a policy module with Network Device Enrollment Service
SDK details
NDES Policy module can be implemented by deriving from
NdesPolicyBaseabstract class. All types here are defined inADCS.CertMod.Managed.NDESnamespace.This class implements
INDESPolicyCOM interface and expose virtual/abstract methods to implementers where you can define your policy's business logic. The following methods can be overridden to implement your business logic:void NdesPolicyBase.OnInitialize()- optional. Invoked by server engine on policy module initialization.void NdesPolicyBase.OnUninitialize()- optional. Invoked by server engine on policy module uninitialization.String OnGenerateChallenge(String, String)- optional. Invoked by server engine when new challenge password is requested by invokinghttps://server/certsrv/mscep_admin?operation=NDESGenerateChallenge&keyUsage=$KeyUsage¶ms=URL. More about default implementation below.Boolean OnVerifyRequest(Byte[]?, Byte[]?, String, String)- mandatory. Invoked by server engine when NDES receives request from SCEP client. If it is a renewal request, signing certificate can be passed to this method by server engine. This is where you should perform challenge password validation if you opted to use them.void OnNotify(String, String, SCEPDisposition, Int32, X509Certificate2? issuedCertificate)- optional. Invoked by server engine when SCEP transaction is completed. Transaction completion doesn't mean that a certificate is issued. Certificate may not be issued, may be placed in pending state, etc. Transaction result is stored indispositionparameter. If challenge passwords are in use, this method MUST be used to remove challenge password from storage.NdesPolicyBaserequires an object that implementsISCEPChallengeStoreinterface. This interface defines a SCEP challenge password storage. This interface exposes the following members:String GetNextChallenge(String, String?)- this is where challenge password is generated and placed into implementation-specific internal storage (runtime dictionary, memory cache, persistent database, etc.). This method SHALL be invoked inNdesPolicyBase.OnGenerateChallengemethod implementation. DefaultNdesPolicyBase.OnGenerateChallengeimplementation performs this call automatically.void ReleaseChallenge(String)- this method is used to remove the challenge password from internal storage when transaction is completed. This method SHALL be invoked inNdesPolicyBase.OnNotifymethod implementation. DefaultNdesPolicyBase.OnNotifyimplementation in performs this call automatically.Boolean TryGetChallenge(String, out SCEPChallengeStoreEntry?)- attempts to retrieve specified challenge password from internal storage. This method SHALL be used inNdesPolicyBase.OnVerifyRequestto verify if challenge password supplied by SCEP client was generated by callingGetNextChallengemethod to avoid replay attacks, for example.You can use
DefaultSCEPChallengeStoreclass which already implementsISCEPChallengeStoreinterface and represents a thread-safe in-memory storage. This storage does not survive SCEP application pool recycle/restart. Challenge password generation is delegated toISCEPChallengeGeneratorwhich requires to implement only one method:String GenerateChallenge()You can use
DefaultSCEPChallengeGeneratorclass which already implementsISCEPChallengeGenerator. Default challenge password generator function generates a cryptographically random challenge of specified size.If default implementations of challenge password generation function and storage satisfy your needs, then your NDES policy module constructor can look like this:
If default implementations of challenge password generation function and storage do not satisfy your needs, you will have to provide an implementation of these interfaces and pass them to base class constructor.
Register custom policy module with NDES service
The following article provides information on registry changes required to register your policy module with NDES: Install a policy module with the Network Device Enrollment Service
Note
You MUST register your assembly as COM object in Windows Registry first.
Caution
Only one NDES policy module can be loaded by NDES service. This means that if you already use custom policy module (for example, Intune NDES policy module), then you will loose Intune implementation when registering another custom policy module.
Caution
NDES challenge password retrieval web portal will stop working after installing custom NDES policy module. This is by design, not a bug. Challenge passwords must be retrieved by explicitly calling password retrieval URL. It looks like this:
where
$KeyUsagemust be a hex value for desired template:0x200x80paramsURL parameter MUST be presented and be empty string if not used.Additional references: