Skip to content

Commit 001262f

Browse files
General improvement on certificate agent settings
1 parent 4faffe2 commit 001262f

File tree

4 files changed

+287
-54
lines changed

4 files changed

+287
-54
lines changed

certificate-agent-config.yaml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
certificate-management: v1
2+
13
infisical:
24
address: "https://app.infisical.com/"
35

@@ -9,28 +11,26 @@ auth:
911
remove_client_secret_on_read: false
1012

1113
certificates:
12-
- profile-id: "5882cac9-b182-4209-a311-64b7c12c4610"
14+
- profile-name: "my-profile-name"
15+
project-slug: "my-project-slug"
1316

1417
# Certificate parameters
15-
common-name: "api.mycompany.com"
16-
alt-names:
17-
- "www.api.mycompany.com"
18-
- "internal-api.mycompany.com"
19-
key-algorithm: "RSA_2048"
20-
signature-algorithm: "RSA-SHA256"
21-
key-usages:
22-
- "digital_signature"
23-
- "key_encipherment"
24-
extended-key-usages:
25-
- "server_auth"
26-
27-
# Certificate lifecycle configuration
28-
ttl: "30d"
18+
attributes:
19+
common-name: "api.mycompany.com"
20+
alt-names:
21+
- "www.api.mycompany.com"
22+
- "internal-api.mycompany.com"
23+
key-algorithm: "RSA_2048"
24+
signature-algorithm: "RSA-SHA256"
25+
key-usages:
26+
- "digital_signature"
27+
- "key_encipherment"
28+
extended-key-usages:
29+
- "server_auth"
30+
ttl: "30d"
2931
lifecycle:
30-
renew-before-expiry: "7d" # When to start checking for renewal before expiration
32+
renew-before-expiry: "1d" # When to start checking for renewal before expiration
3133
status-check-interval: "6h" # How often to check certificate status and renewal needs
32-
max-failure-retries: 3 # Maximum number of failed operation retries before giving up
33-
failure-retry-interval: "1h" # How long to wait between failed operation retry attempts
3434

3535
# Post-hooks for automation
3636
post-hooks:

packages/api/api.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,45 @@ func CallGetProjectById(httpClient *resty.Client, id string) (Project, error) {
294294
return projectResponse.Project, nil
295295
}
296296

297+
func CallGetProjectBySlug(httpClient *resty.Client, slug string) (Project, error) {
298+
var projectResponse GetProjectBySlugResponse
299+
response, err := httpClient.
300+
R().
301+
SetResult(&projectResponse).
302+
SetHeader("User-Agent", USER_AGENT).
303+
Get(fmt.Sprintf("%v/v1/projects/slug/%s", config.INFISICAL_URL, slug))
304+
305+
if err != nil {
306+
return Project{}, NewGenericRequestError("CallGetProjectBySlug", err)
307+
}
308+
309+
if response.IsError() {
310+
return Project{}, NewAPIErrorWithResponse("CallGetProjectBySlug", response, nil)
311+
}
312+
313+
return Project(projectResponse), nil
314+
}
315+
316+
func CallGetCertificateProfileBySlug(httpClient *resty.Client, projectId, slug string) (CertificateProfile, error) {
317+
var profileResponse GetCertificateProfileResponse
318+
response, err := httpClient.
319+
R().
320+
SetResult(&profileResponse).
321+
SetHeader("User-Agent", USER_AGENT).
322+
SetQueryParam("projectId", projectId).
323+
Get(fmt.Sprintf("%v/v1/cert-manager/certificate-profiles/slug/%s", config.INFISICAL_URL, slug))
324+
325+
if err != nil {
326+
return CertificateProfile{}, NewGenericRequestError("CallGetCertificateProfileBySlug", err)
327+
}
328+
329+
if response.IsError() {
330+
return CertificateProfile{}, NewAPIErrorWithResponse("CallGetCertificateProfileBySlug", response, nil)
331+
}
332+
333+
return profileResponse.CertificateProfile, nil
334+
}
335+
297336
func CallIsAuthenticated(httpClient *resty.Client) bool {
298337
var workSpacesResponse GetWorkSpacesResponse
299338
response, err := httpClient.

packages/api/model.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,21 @@ type GetProjectByIdResponse struct {
136136
Project Project `json:"workspace"`
137137
}
138138

139+
type GetProjectBySlugResponse Project
140+
141+
type CertificateProfile struct {
142+
ID string `json:"id"`
143+
Name string `json:"name"`
144+
Description string `json:"description"`
145+
ProjectID string `json:"projectId"`
146+
CaID string `json:"caId"`
147+
CertificateTemplateID string `json:"certificateTemplateId"`
148+
}
149+
150+
type GetCertificateProfileResponse struct {
151+
CertificateProfile CertificateProfile `json:"certificateProfile"`
152+
}
153+
139154
type GetOrganizationsResponse struct {
140155
Organizations []struct {
141156
ID string `json:"id"`

0 commit comments

Comments
 (0)