cancel
Showing results for 
Search instead for 
Did you mean: 

How to upload the SSL certificates from application server or presentation server into ABAP system.

naresh_vemireddy
Explorer
0 Kudos
469

Hi Experts,

Good Morning.

We have requirement which related automate the Strustss02 functionality through APIs .

In the above requirement ,we need to download the certificates from specified portal and need to upload the certificates into the system.

Kindly let me know is there any BAPI are available for this functionality.

Thank you,

Naresh.V

srikanthnalluri
Active Participant
0 Kudos
I don't think we can upload certificates into STRUST t code using a BAPI,
dmcardlenl
Participant
0 Kudos
sapgenpse maintain_pk -a

Accepted Solutions (0)

Answers (2)

Answers (2)

umasaral
Participant
0 Kudos

Hi Naresh,

Sure, I can help with that! Lets break down the process into the three steps you mentioned and provide some details and examples. Downloading Certificates Using SAP GUI Scripting or Automation Tools-To automate the process of downloading certificates from a portal using SAP GUI Scripting, you would typically use the scripting language to simulate user interactions within the SAP GUI.
 
Example SAP GUI Script in VBscript:
Dim SapGuiAuto, application, connection, session
Dim downloadButton, filePath
 
Create the SAP GUI Scripting objects
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
Set connection = application.Children(0)
Set session = connection.Children(0)
 
Navigate to the relevant screen (replace with actual navigation steps)
session.findById("wnd[0]/tbar[0]/okcd").text = "/nSM59"
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/usr/txtRFCDEST").text = "MY_DESTINATION"
session.findById("wnd[0]/tbar[1]/btn[8]").press
 
 Example of interacting with a dialog to download certificates
session.findById("wnd[0]/usr/btnCERT_DOWNLOAD").press
 
Assuming a file dialog appears; set the file path
filePath = "C:\path\to\save\certificate.cer"
session.findById("wnd[1]/usr/ctxtFILE_PATH").text = filePath
session.findById("wnd[1]/tbar[0]/btn[11]").press
 
 End the script
WScript.Echo "Certificate downloaded to " & filePath
 
 
Saving the Certificates Locally-the script example above saves the certificate file to a specified local path
Uploading Certificates into SAP Using ABAP--To upload certificates into SAP using ABAP, you can use the SECSTORE API or similar methods
 
Here some example:
Step-by-Step Guide:
 
    Read the Certificate File: First, read the certificate file into an internal table or string in ABAP.
    Convert to Binary: Convert the certificate into binary format if needed.
    Use the SECSTORE API: Call the appropriate methods from the SECSTORE API to upload the certificate.
 
DATA: lv_file_path TYPE string VALUE 'C:\path\to\save\certificate.cer',
      lv_cert_data TYPE xstring,
      lv_cert_name TYPE string VALUE 'MY_CERTIFICATE_NAME'.
 
* Read the certificate file into an xstring
CALL METHOD cl_gui_frontend_services=>gui_upload
  EXPORTING
    filename                = lv_file_path
  IMPORTING
    filelength              = lv_file_size
  CHANGING
    data_tab                = lv_cert_data
  EXCEPTIONS
    others                  = 1.
 
IF sy-subrc <> 0.
  WRITE: / 'Error reading file'.
  EXIT.
ENDIF.
 
* Create or update the certificate in the SAP system
CALL FUNCTION 'SCP_PUBLISH_CERT'
  EXPORTING
    certificate_id = lv_cert_name
    certificate    = lv_cert_data
  EXCEPTIONS
    others         = 1.
 
IF sy-subrc <> 0.
  WRITE: / 'Error uploading certificate'.
  EXIT.
ENDIF.
 
WRITE: / 'Certificate uploaded successfully'.
 
Note:
If the function module or method to upload certificates is different in your SAP environment, make sure to adapt the example accordingly.
 Always test your code in a development or test environment before using it in production.
umasaral
Participant
0 Kudos

Good morning! To automate the downloading and uploading of certificates, specifically related to SAP's Secure Store (transaction `Strustss02`), you typically won't find specific Business Application Programming Interfaces (BAPIs) for this directly. However, you can achieve this automation through various methods depending on your system landscape and requirements.

Approach to Automate Strustss02 Functionality:

1. SAP Cryptographic Library (STRUST):
- `Strustss02` is used for managing SSL client SSL client (X.509) certificates and cryptographic configurations in SAP systems.
- Instead of BAPIs, SAP provides APIs and tools that can interact with cryptographic functionalities indirectly.

2. Automation Tools and Scripts:
- Consider using automation scripts or tools that can interact with SAP transactions via GUI scripting or SAP GUI scripting (available in SAP GUI for Windows).
- Tools like SAP Solution Manager Automation (SMA) or third-party automation tools can automate the downloading and uploading process by simulating user actions.

3. SAP Cryptographic Library API:
- SAP provides the `SECSTORE` API for cryptographic operations, which might be indirectly related to `Strustss02` functionality.
- You can explore if this API can be leveraged to automate certain aspects of certificate management within SAP.

4. Custom Development:
- For more advanced integration, consider developing custom ABAP programs that utilize SAP's cryptographic services and APIs to handle certificate downloads and uploads programmatically.
- ABAP classes such as `CL_HTTPS_CLIENT` and `CL_HTTPS_REQUEST` might be useful for handling HTTPS connections and certificate management in custom developments.

5. SAP Note and Documentation:
- Review relevant SAP Notes and documentation for `Strustss02` and cryptographic library functionalities. These resources often provide insights into supported APIs and best practices for certificate management.

Example Scenario:

Assuming you need to download certificates from a specified portal and upload them into SAP via `Strustss02`:
- Use SAP GUI scripting or automation tools to simulate the steps of downloading certificates from the portal.
- Save the certificates locally.
- Develop an ABAP program to upload these certificates into `Strustss02` using `SECSTORE` API or relevant methods.


While direct BAPIs for `Strustss02` might not exist, you can achieve automation through a combination of SAP GUI scripting, custom ABAP developments, and leveraging SAP's cryptographic APIs. This approach ensures efficient and controlled management of SSL certificates within your SAP system. If specific functionalities are not directly supported, exploring custom development or third-party integration options can provide the necessary automation capabilities.

naresh_vemireddy
Explorer
0 Kudos

Hi Umasaral, Thank you for explaining the Below scenario.

 

Example Scenario:

Assuming you need to download certificates from a specified portal and upload them into SAP via `Strustss02`:
- 1.Use SAP GUI scripting or automation tools to simulate the steps of downloading certificates from the portal.
- 2.Save the certificates locally.
- 3.Develop an ABAP program to upload these certificates into `Strustss02` using `SECSTORE` API or relevant methods

 

 

Can you please explain the 3 point elaborately.

Can you please provide the API if possible and also provide the SAP GUI Scripting with example.

Thank you,

Naresh.V