-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
Added sign certificate functionality of PKI secret engine. #192
Conversation
… CertificateRequestOptions for PKI engine. Added example in README.md and small note in CHANGELOG.md.
Checker.NotNull(signCertificatesRequestOptions, "signCertificatesRequestOptions"); | ||
|
||
var result = await _polymath.MakeVaultApiRequest<Secret<SignedCertificateData>>(pkiBackendMountPoint ?? _polymath.VaultClientSettings.SecretsEngineMountPoints.PKI, "/sign/" + pkiRoleName, HttpMethod.Post, signCertificatesRequestOptions, wrapTimeToLive: wrapTimeToLive).ConfigureAwait(_polymath.VaultClientSettings.ContinueAsyncTasksOnCapturedContext); | ||
result.Data.CertificateFormat = signCertificatesRequestOptions.CertificateFormat; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs a null check on result.Data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's assigned as in GetCredentialsAsync function. Thought that there will be some exception, error code from Api if there will be no data send. For my purpose i don't even need that CertificateFormat Assigned cause as a caller you already know it.
[JsonProperty("csr")] | ||
public string Csr { get; set; } | ||
|
||
/// <summary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this. redundant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you right. Removed Abstract class and created separate classes for both endpoints so this one is fixed too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor
/// <summary> | ||
/// Represents the Certificate request options. | ||
/// </summary> | ||
public abstract class AbstractCertificateRequestOptions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please replicate the class for your need and leave the original POCO intact?
For payload classes, I am deliberately avoiding inheritance to decouple them.
/// <summary> | ||
/// Initializes a new instance of the <see cref="CertificateCredentialsRequestOptions"/> class. | ||
/// </summary> | ||
public CertificateCredentialsRequestOptions() | ||
public CertificateCredentialsRequestOptions() : base() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for base() right?
Checker.NotNull(signCertificatesRequestOptions, "signCertificatesRequestOptions"); | ||
|
||
var result = await _polymath.MakeVaultApiRequest<Secret<SignedCertificateData>>(pkiBackendMountPoint ?? _polymath.VaultClientSettings.SecretsEngineMountPoints.PKI, "/sign/" + pkiRoleName, HttpMethod.Post, signCertificatesRequestOptions, wrapTimeToLive: wrapTimeToLive).ConfigureAwait(_polymath.VaultClientSettings.ContinueAsyncTasksOnCapturedContext); | ||
result.Data.CertificateFormat = signCertificatesRequestOptions.CertificateFormat; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property is not marked with JsonIgnore... Either we should let json set it, or if we are explicitly setting it, it should be marked with json-ignore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CertificateFormat property is marked as JsonIgnore in AbstractCertificateData class. Or maybe I am referring to wrong property?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it. i was looking at the request poco by mistake.
…tracted details to SignCertificateRequestOptions class
thanks @slutkiewicz for the pr and for using the library |
i'll get this published within 7 days max. maybe faster. |
it was faster. @slutkiewicz Your fix is published: |
PKI secret engine sign certificate endpoint implementation.