Easy to use class for adding, updating, or removing certificates from ABAP Trust Management (transaction STRUST)
NO WARRANTIES, MIT License
Example of creating, updating, or removing a certificate using class zcl_strust2
.
CONSTANTS:
c_sslc TYPE psecontext VALUE 'SSLC' ##NO_TEXT,
c_anonym TYPE ssfappl VALUE 'ANONYM' ##NO_TEXT,
c_id TYPE ssfid VALUE 'CN=%SID SSL client SSL Client (Standard), OU=%ORG, O=MBT, C=CA' ##NO_TEXT,
c_org TYPE string VALUE 'Marc Bernard Tools' ##NO_TEXT,
c_subject TYPE string VALUE 'CN=*.marcbernardtools.com' ##NO_TEXT.
DATA:
lo_strust TYPE REF TO zcl_strust2,
lx_error TYPE REF TO zcx_strust2.
TRY.
CREATE OBJECT lo_strust
EXPORTING
iv_context = c_sslc
iv_applic = c_anonym.
lo_strust->load(
iv_create = abap_true
iv_id = c_id
iv_org = c_org ).
lo_strust->get_own_certificate( ).
lo_strust->get_certificate_list( ).
IF iv_drop = abap_true.
lo_strust->remove( c_subject ).
ELSE.
" Root and intermediate certificates
" lo_strust->add( _get_certificate_ca( ) )
" lo_strust->add( _get_certificate_ica( ) )
lo_strust->add( _get_certificate_mbt( ) ).
lo_strust->update( ).
ENDIF.
CATCH zcx_strust2 INTO lx_error.
MESSAGE lx_error TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.
The certificate for the add
method needs to be provided as a table with the following format:
-----BEGIN CERTIFICATE-----
MIIGQDCCBSigAwIBAgIQCNqWSvYNNa9hfOzsk89rUjANBgkqhkiG9w0BAQsFADBg
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
...
-----END CERTIFICATE-----
SAP Basis 7.02 or higher
Install strust
as a global module in your system using apm.
or
Specify the strust
module as a dependency in your project and import it to your namespace using apm.
All contributions are welcome! Read our Contribution Guidelines, fork this repo, and create a pull request.
You can install the developer version of ABAP STRUST using abapGit by creating a new online repository for https://github.com/abapPM/ABAP-Strust
.
Recommended SAP package: $STRUST
Made with ❤ in Canada
Copyright 2025 apm.to Inc. https://apm.to