Skip to content

Commit

Permalink
add support email address
Browse files Browse the repository at this point in the history
  • Loading branch information
iishabakaev committed Aug 19, 2024
1 parent b9d9d41 commit 8912515
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/cdktf/python/resources/cert_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,6 @@ Optional:
- `province` (String) Distinguished name: `ST`
- `serial_number` (String) Distinguished name: `SERIALNUMBER`
- `street_address` (List of String) Distinguished name: `STREET`
- `email_address` (String) Email address: `emailAddress (x509 1.2.840.113549.1.9.1)`

<!-- cache-key: cdktf-0.20.1 input-f0b329ca4c0554d420316e3aa077babdcc26589666ed69b639e7ed93d15ac558 -->
1 change: 1 addition & 0 deletions docs/cdktf/python/resources/self_signed_cert.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Optional:
- `province` (String) Distinguished name: `ST`
- `serial_number` (String) Distinguished name: `SERIALNUMBER`
- `street_address` (List of String) Distinguished name: `STREET`
- `email_address` (String) Email address: `emailAddress (x509 1.2.840.113549.1.9.1)`

## Automatic Renewal

Expand Down
1 change: 1 addition & 0 deletions docs/resources/cert_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ Optional:
- `province` (String) Distinguished name: `ST`
- `serial_number` (String) Distinguished name: `SERIALNUMBER`
- `street_address` (List of String) Distinguished name: `STREET`
- `email_address` (String) Email address: `emailAddress (x509 1.2.840.113549.1.9.1)`
1 change: 1 addition & 0 deletions docs/resources/self_signed_cert.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Optional:
- `province` (String) Distinguished name: `ST`
- `serial_number` (String) Distinguished name: `SERIALNUMBER`
- `street_address` (List of String) Distinguished name: `STREET`
- `email_address` (String) Email address: `emailAddress (x509 1.2.840.113549.1.9.1)`

## Automatic Renewal

Expand Down
7 changes: 7 additions & 0 deletions internal/provider/common_cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,5 +386,12 @@ func createSubjectDistinguishedNames(ctx context.Context, subject certificateSub
result.SerialNumber = subject.SerialNumber.ValueString()
}

if !subject.EmailAddress.IsNull() && !subject.EmailAddress.IsUnknown() {
result.ExtraNames = append(result.ExtraNames, pkix.AttributeTypeAndValue{
Type: []int{1, 2, 840, 113549, 1, 9, 1},
Value: subject.EmailAddress.ValueString(),
})
}

return result
}
1 change: 1 addition & 0 deletions internal/provider/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type certificateSubjectModel struct {
Country types.String `tfsdk:"country"`
PostalCode types.String `tfsdk:"postal_code"`
SerialNumber types.String `tfsdk:"serial_number"`
EmailAddress types.String `tfsdk:"email_address"`
}

type privateKeyResourceModel struct {
Expand Down
7 changes: 7 additions & 0 deletions internal/provider/resource_cert_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,13 @@ func (r *certRequestResource) Schema(_ context.Context, req resource.SchemaReque
},
Description: "Distinguished name: `SERIALNUMBER`",
},
"email_address": schema.StringAttribute{
Optional: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
Description: "Email Address: `1.2.840.113549.1.9.1`",
},
},
},
MarkdownDescription: "The subject for which a certificate is being requested. " +
Expand Down

0 comments on commit 8912515

Please sign in to comment.