-
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added sign certificate functionality of PKI secret engine. (#192)
* Added sign certificate functionality of PKI secret engine. Abstracted CertificateRequestOptions for PKI engine. Added example in README.md and small note in CHANGELOG.md. * fixed ref copy paste typo in SignCertificateRequestOptions * Restored original CerificateCredentialsRequestOptions class moved abstracted details to SignCertificateRequestOptions class Co-authored-by: Stanisław Lutkiewicz <stanislaw.lutkiewicz@softgent.com>
- Loading branch information
Showing
6 changed files
with
185 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
122 changes: 122 additions & 0 deletions
122
src/VaultSharp/V1/SecretsEngines/PKI/SignCertificateRequestOptions.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace VaultSharp.V1.SecretsEngines.PKI | ||
{ | ||
/// <summary> | ||
/// Represents the Sign Certificate request options. | ||
/// </summary> | ||
public class SignCertificatesRequestOptions | ||
{ | ||
/// <summary> | ||
/// <para>[required]</para> | ||
/// Specifies the PEM-encoded CSR | ||
/// </summary> | ||
/// <value> | ||
/// Encoded CSR. | ||
/// </value> | ||
[JsonProperty("csr")] | ||
public string Csr { get; set; } | ||
|
||
/// <summary> | ||
/// <para>[required]</para> | ||
/// Gets or sets the requested CN for the certificate. | ||
/// If the CN is allowed by role policy, it will be issued. | ||
/// </summary> | ||
/// <value> | ||
/// The name of the common. | ||
/// </value> | ||
[JsonProperty("common_name")] | ||
public string CommonName { get; set; } | ||
|
||
/// <summary> | ||
/// <para>[optional]</para> | ||
/// Gets or sets the requested Subject Alternative Names, in a comma-delimited list. | ||
/// These can be host names or email addresses; they will be parsed into their respective fields. | ||
/// If any requested names do not match role policy, the entire request will be denied. | ||
/// </summary> | ||
/// <value> | ||
/// The subject alternative names. | ||
/// </value> | ||
[JsonProperty("alt_names")] | ||
public string SubjectAlternativeNames { get; set; } | ||
|
||
/// <summary> | ||
/// <para>[optional]</para> | ||
/// Gets or sets the requested IP Subject Alternative Names, in a comma-delimited list. | ||
/// Only valid if the role allows IP SANs (which is the default). | ||
/// </summary> | ||
/// <value> | ||
/// The ip subject alternative names. | ||
/// </value> | ||
[JsonProperty("ip_sans")] | ||
public string IPSubjectAlternativeNames { get; set; } | ||
|
||
/// <summary> | ||
/// <para>[optional]</para> | ||
/// Gets or sets the requested URI Subject Alternative Names, in a comma-delimited list. | ||
/// </summary> | ||
/// <value> | ||
/// The uri subject alternative names. | ||
/// </value> | ||
[JsonProperty("uri_sans")] | ||
public string URISubjectAlternativeNames { get; set; } | ||
|
||
/// <summary> | ||
/// <para>[optional]</para> | ||
/// Gets or sets the custom OID/UTF8-string SANs. | ||
/// These must match values specified on the role in allowed_other_sans (globbing allowed). | ||
/// The format is the same as OpenSSL: [oid];[type]:[value] where the only current valid type is UTF8. | ||
/// This can be a comma-delimited list or a JSON string slice. | ||
/// </summary> | ||
/// <value> | ||
/// The other subject alternative names. | ||
/// </value> | ||
[JsonProperty("other_sans")] | ||
public string OtherSubjectAlternativeNames { get; set; } | ||
|
||
/// <summary> | ||
/// <para>[optional]</para> | ||
/// Gets or sets the requested Time To Live. | ||
/// Cannot be greater than the role's max_ttl value. | ||
/// If not provided, the role's ttl value will be used. | ||
/// Note that the role values default to system values if not explicitly set. | ||
/// </summary> | ||
/// <value> | ||
/// The time to live. | ||
/// </value> | ||
[JsonProperty("ttl")] | ||
public string TimeToLive { get; set; } | ||
|
||
/// <summary> | ||
/// <para>[optional]</para> | ||
/// Gets or sets the certificate format for returned data. | ||
/// Can be pem or der; defaults to pem. | ||
/// If der, the output is base64 encoded.. | ||
/// </summary> | ||
/// <value> | ||
/// The certificate format. | ||
/// </value> | ||
[JsonProperty("format")] | ||
public CertificateFormat CertificateFormat { get; set; } | ||
|
||
/// <summary> | ||
/// <para>[optional]</para> | ||
/// Gets or sets a value indicating whether [exclude common name from subject alternative names]. | ||
/// If set, the given common name will not be included in DNS or Email Subject Alternate Names (as appropriate). | ||
/// Useful if the CN is not a hostname or email address, but is instead some human-readable identifier. | ||
/// </summary> | ||
/// <value> | ||
/// <c>true</c> if [exclude common name from subject alternative names]; otherwise, <c>false</c>. | ||
/// </value> | ||
[JsonProperty("exclude_cn_from_sans")] | ||
public bool ExcludeCommonNameFromSubjectAlternativeNames { get; set; } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="SignCertificatesRequestOptions"/> class. | ||
/// </summary> | ||
public SignCertificatesRequestOptions() | ||
{ | ||
CertificateFormat = CertificateFormat.pem; | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/VaultSharp/V1/SecretsEngines/PKI/SignedCertificateData.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace VaultSharp.V1.SecretsEngines.PKI | ||
{ | ||
/// <summary> | ||
/// Represents the signed Certificate. | ||
/// </summary> | ||
public class SignedCertificateData : AbstractCertificateData | ||
{ | ||
|
||
} | ||
} |