@@ -2324,11 +2324,19 @@ create or replace package body iot_oci as
23242324 v_config json_object_t; -- Config
23252325 v_return json_object_t; -- JSON output for status/PEM/chain/private
23262326 results dbms_cloud_oci_cert_certificates_get_certificate_bundle_response_t; -- API response
2327+ get_cert_results dbms_cloud_oci_certm_certificates_management_get_certificate_response_t;
2328+ cert_cn varchar2(100); -- store common name of certificate
23272329 begin
23282330
23292331 -- Fetch the OCI configuration from the app-owned table
23302332 v_config := iot_apex.iot_config; -- Get the OCI configuration
23312333
2334+ get_cert_results := dbms_cloud_oci_certm_certificates_management.get_certificate(
2335+ certificate_id => p_cert_ocid, -- Certificate OCID
2336+ region => v_config.get_string('tenancy_region'), -- Region
2337+ credential_name => v_config.get_string('credentials') -- Credential name
2338+ );
2339+
23322340 -- Call the OCI API to get the certificate bundle
23332341 results := dbms_cloud_oci_cert_certificates.get_certificate_bundle(
23342342 certificate_id => p_cert_ocid, -- Certificate OCID
@@ -2337,10 +2345,18 @@ create or replace package body iot_oci as
23372345 credential_name => v_config.get_string('credentials') -- Credential name
23382346 ); -- Get the certificate bundle
23392347
2348+ if get_cert_results.status_code = '200' then -- check for success of get_certificate
2349+ cert_cn := treat(
2350+ treat(
2351+ get_cert_results.response_body as dbms_cloud_oci_certificates_management_certificate_t
2352+ ).subject as dbms_cloud_oci_certificates_management_certificate_subject_t
2353+ ).common_name;
2354+ end if;
2355+
23402356 -- Package the result for output as a JSON clob
23412357 v_return := json_object_t(); -- Create a new JSON object
23422358 v_return.put('status',results.status_code); -- Status code of the API response
2343-
2359+ v_return.put('common_name',cert_cn); -- common name of the cert
23442360 v_return.put('cert_pem',
23452361 treat(
23462362 results.response_body as dbms_cloud_oci_certificates_certificate_bundle_t
0 commit comments