Skip to content

Latest commit

 

History

History
93 lines (64 loc) · 3.31 KB

README.md

File metadata and controls

93 lines (64 loc) · 3.31 KB

Version

License Contributor Covenant REUSE Status

Trust Management

Easy to use class for adding, updating, or removing certificates from ABAP Trust Management (transaction STRUST)

Made by Marc Bernard Tools giving back to the SAP Community

NO WARRANTIES, MIT License

Usage

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-----

Prerequisites

SAP Basis 7.02 or higher

Installation

You can install this module using abapGit either creating a new online repository for https://github.com/Marc-Bernard-Tools/ABAP-Strust or downloading the repository ZIP file and creating a new offline repository.

Recommended SAP package: $ABAP-STRUST.

Contributions

All contributions are welcome! Read our Contribution Guidelines, fork this repo, and create a pull request.

About

Made with ❤️ in Canada

Copyright 2024 Marc Bernard https://marcbernardtools.com/

Follow @marcfbe on Twitter

MBT Logo