Zertifikats-Handling SAP mithilfe der SAP Crypto-lib / SAPGENPSE und der STRUST

Die SAP Transaktion STRUST ist für das Zertifikats-Management in den SAP Systemen verantwortlich. Hierbei verwendet die Transaktion STRUST eine sogenannte PSE – die hier als „Zertifikats-Storage“ analog des Java-Keystore verwendet werden.
Grundsätzlich kann man dort nur ein einziges privates Zertifikat ablegen!

In der Transaktion STRUST lassen sich Zertifikate grundsätzlich auch generieren. Die Verwendung von alternativen DNS-Attributen hingegen ist dort nicht möglich.

Benötigte Software:

Aus der SAP Hilfe

  1. Navigieren Sie zur Seite http://service.sap.com/swcenter.
  2. Melden Sie sich mit Ihrer SAP S-User ID an und navigieren Sie zu Download → SAP Cryptographic Software.

Die folgenden Schritte sind ursächlich von diesem Artikel inspiriert:
https://blogs.sap.com/2015/10/26/subject-alternative-name-san-with-sapgenpse-commoncryptolib/

Um alternative DNS-Namen – die nicht aus dem Common-Name (CN) stammen muss man mithilfe des Kommandozeilen-Werkzeugs SAPGENPSE aus der SAP Crypto-lib die PSE erzeugen. Dies ist auch auf Windows und Betriebssystemzugang zum SAP System möglich – wenngleich das „sapgenpse“ auf den Servern bei installierter SAP Crypto-Lib immer verfügbar ist.

Grundsätzlich muss die Umgebungsvariable SECUDIR nach der Installation gesetzt werden.

Mit dem folgenden Befehl wird eine neue PSE (ohne Passwort) mit eine Schlüsselstärke von 4096 bit und dem SHA256 generiert – der Certificate-Signing-Request (CSR) wird am ende gleich mit ausgespuckt:

sapgenpse gen_pse -s 4096 -a sha256WithRsaEncryption -p NEUE_PSE.pse "CN=mein.server.org, OU=meineorganisation@server.org, O=Meinefirme, C=DE"

Wenn der folgende Parameter mitverwendet wird (ein – bis mehrfach) können weitere DNS-Namen die für den Server gültig sind mit als Alias eingefügt werden.  Dies geht auch für Emails – nach einem alias:

sapgenpse gen_pse -s 4096 -a sha256WithRsaEncryption -p NEUE_PSE.pse
-k GN-dNSName:einandereralias.server.org
-k GN-rfc822Name:meineorganisation@server.org
"CN=mein.server.org, OU=meineorganisation@server.org, O=Meinefirme, C=DE"

Die Zertifikatsantwort kann dann mit dem folgenden Befehl eingelesen werden:

sapgenpse import_own_cert -p NEUE_PSE.ps -c fiorie.pem

Anschliessend muss in die STRUST im Zielsystem auf Änderbar gestellt werden und mit „importieren – Speichern als“ die neue PSE für den Zielzweck – meist SSL-Server gespeichert werden.

 

Anmerkung – bei mir musste zuerst die PSE für Web-Server komplett gelöscht werden. Ansonsten war in den Server instanzen noch das alte Zertifikat vorhanden.

Grundsätzlich ist es auch möglich mithilfe des Werkzeugs ein in z.b. OpenSSL erzeugtes Zertifikat und die komplette Vertrauenskette so in eine PSE umzuwandeln.
Man-Page / Hilfe des Generierungsbefehls
sapgenpse gen_pse -h
Create a new PSE and a PKCS#10 certification request or
or create a (renewal) PKCS#10 certification request for an existing PSE
Usage: gen_pse -p [other-options] [Distinguished name]
Options:
-p filename for (new) PSE
-r filename for PKCS#10 request (default: stdout)
-lps use LPS to protect the new PSE
-a algorithm DSA, ECDSA or RSA (default is RSA)
with GOST plugin: GostR3410-2001
-a also supports an extended syntax for specifying
key type, strength and signature algorithm:
Use this syntax if the CA requires that the certification
request is signed with a specific algorithm:
::
keyType : DSA, ECDSA or RSA
strength : key size or the name of the ECDSA curve
(P-192, P-224, P-256, P-384 or P-521)
hashAlg : hash algorithm used for the signature
of the self signed certificate
and the certification request
(SHA1, SHA224, SHA256, SHA384, SHA512)
Examples:
RSA:2048:SHA256
DSA:1024:SHA1
ECDSA:P-256:SHA1
-s key size in Bits (default=alg-specific, rsa=DEFAULT_RSA_KEYSIZE
, dsa=DEFAULT_DSA_KEYSIZE)
-x PIN/Passphrase for PSE (default: query interactively)
-noreq do not create/print a PKCS#10 certification request
-onlyreq create PKCS#10 certification request for an existing PSE
-2 create PSE format v2
-4 create PSE format v4
-j Add Subject Alternative Names from existing PSE certificate
to the certification request (with -onlyreq).
-k Add Subject Alternative Names to the certification request.
Multiple -k parameters are supported to create a list
of alternative names in the request.
If the type of the name is not derivable, the respective prefix
must be given:
'GN-rfc822Name:', 'GN-dNSName:', 'GN-uRI:',
'GN-iPAddress:', 'GN-directoryName:', 'GN-registeredID:'
Syntax to specify a name of type 'otherName':
GN-otherName:::
oid : 'UPN' or object identifier (1.2.840...)
valueType: Encoding type of value
'HEX': value is hex string of ASN.1 DERCode
'UTF8String': value will be encoded as UTF8String
value : Name value (hex ASN.1 DERCode or string)
Examples:
-k GN-dNSName:www.sap.com
-k GN-iPAddress:127.0.0.1
-k GN-otherName:UPN:UTF8String:john.doe@sap.com
-k GN-otherName:1.3.6.1.4.1.694.2.2.2.444:HEX:0403020507
-h print this help
-v verbose
Examples:
- create an lps protected file SAPSNCS.pse with server DName
(prompts for PSE password)
sapgenpse gen_pse -lps -p SAPSNCS.pse "CN=SAPServerABC, C=DE"
- create an lps protected file SAPSNCS.pse with 2048 RSA key and SHA256 Hash Alg
orithm
(prompts for PSE password)
sapgenpse gen_pse -lps -p SAPSNCS.pse - a RSA:2048:SHA256 "CN=SAPServerABC, C=
DE"
- create PKCS#10 certification request for an existing PSE
sapgenpse gen_pse -p SAPSNCS.pse -onlyreq -r cert.p10
- create an lps protected file SAPSNCS1.pse with server DName and PKCS#10 Reques
t
(prompts for PSE password)
sapgenpse gen_pse -lps -p SAPSNCS1.pse "CN=SAPServerABC1, C=DE" -r cert1.p10
- create an file SAPSSLS.pse with server DName and 2 DNS as SubjectAltName
(prompts for PSE password)
sapgenpse gen_pse -p SAPSSLS.pse -k GN-dNSName:www.sap.com "CN=www.sap.de, DNS
=www.sap.fr, C=DE"
- Add Subject Alternative Names from the existing SAPSSLS.pse in the certificate
request
(prompts for PSE password)
sapgenpse gen_pse -p SAPSSLS.pse -j -onlyreq -r cert.p10


Beitrag veröffentlicht

in

von