You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "ertanci (via GitHub)" <gi...@apache.org> on 2025/01/31 07:03:23 UTC
Re: [I] bug: uploading a cert via api - it is accepted with no error, shows in dashboard with correct SNI, but invalid expiry date. Cert can NOT be deleted [apisix]
ertanci commented on issue #8665:
URL: https://github.com/apache/apisix/issues/8665#issuecomment-2626448286
Hi,
It is solved setting validity_end parameter in body. I am using ansible for these operation.
Using the certificate I was able to obtain the validity_end parameter before calling the API. In order to be clearly understood, I want to add partial code.
- name: Get the expiration date of the certificate
command: "openssl x509 -enddate -noout -in /tmp/public.crt"
register: cert_expiration
- name: Extract date from openssl output
set_fact:
expiration_date: "{{ cert_expiration.stdout | regex_replace('notAfter=', '') }}"
- name: Convert expiration date to epoch
shell: "date -d '{{ expiration_date }}' +%s"
register: expiration_epoch
- name: Show the expiration date in epoch
debug:
msg: "The certificate expires on {{ expiration_date }} which is {{ expiration_epoch.stdout }} in epoch time."
- name: Add ssl list in apisix
uri:
url: "https://{{ apix_admin_endpoint }}/apisix/admin/ssls"
method: POST
body: |
{
"cert": "{{ decoded_cert }}",
"key": "{{ decoded_key }}",
"snis": ["{{ apix_snis }}"],
"validity_end": {{ expiration_epoch.stdout }}
}
body_format: json
headers:
X-API-KEY: "{{ apisix_key.stdout | trim }}"
Content-Type: application/json
register: response
failed_when: response.status not in [200, 201]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org