Get HTTPS certificates from a Web site via the ICM trace (transaction code SMICM) and upload them to STRUST.
EDIT: the ICM trace outputs the certificate contents in ABAP 7.52 but not in ABAP 7.58 (see more information and workaround in https://github.com/sandraros/zcerti/issues/6).
Initial idea from here to read the ICM trace and parse the certificates, and credits to MBT here for uploading the certificates to STRUST.
Program ZCERTI_DEMO
:
Excerpts of ZCERTI_DEMO
source code:
DATA(icm_trace_api) = zcl_certi_icm_trace=>create( ).
DATA(original_trace_level) = icm_trace_api->get_trace_level( ).
icm_trace_api->set_trace_level( '3' ). " highest details to get certificate contents
icm_trace_api->delete_trace( ).
DATA(parsed_icm_trace) = icm_trace_api->get_parsed_trace( ).
icm_trace_api->set_trace_level( original_trace_level ).
LOOP AT parsed_icm_trace-certificates REFERENCE INTO DATA(certificate).
...
ENDLOOP.
zcl_certi_mbt_strust
= exact copy of class /mbtools/cl_strust
, GPL 3.0 License):
DATA(strust) = NEW zcl_certi_mbt_strust( iv_context = 'SSLC' iv_applic = 'ANONYM' ).
strust->load( ).
strust->get_own_certificate( ).
DATA(certificates) = strust->get_certificate_list( ).
LOOP AT parsed_icm_trace-certificates REFERENCE INTO certificate.
strust->add( CONV #( certificate->lines ) ).
ENDLOOP.
strust->update( ).
COMMIT WORK.