/zcerti

Get HTTPS certificates from ICM trace and update in STRUST

Primary LanguageABAPMIT LicenseMIT

zcerti

Get HTTPS certificates from a Web site via the ICM trace (transaction code SMICM) and upload them to STRUST.

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:

image

Excerpts of ZCERTI_DEMO source code:

  • Start and parse the ICM trace to get the certificates:
    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.
  • Update STRUST SSL Client PSE (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.