Integration
MYSAPSSO2 on BTP: Principal Propagation Without PrincipalPropagation — Forwarding SSO Cookies Through SAP Cloud Integration
Vlado Balko

Forward MYSAPSSO2 cookies through SCI iFlows to S/4HANA — user identity propagation on BTP without PrincipalPropagation. Plus a debugging tool. Updated June 2026 with corrections and lessons from a real production deployment.
Update (June 2026): After deploying this pattern in production (a CAP Node.js app on BTP issuing tokens directly against S/4HANA, kernel 7.93, CommonCryptoLib 8.5.x), I found two factual errors in the original article and a series of undocumented gotchas that cost days of ICM/SSF trace debugging. The corrections are integrated below and the new section “Errata: What a Real Deployment Taught Me” covers the details — including working Node.js code.
You’re building an integration flow in SAP Cloud Integration (SCI/CPI). The external system sends a SOAP request to your iFlow, which routes it through Cloud Connector to S/4HANA’s /sap/bc/soap/rfc endpoint. Authentication? A MYSAPSSO2 cookie — SAP's cookie-based Single Sign-On token.
Everything works in the test system. Then you move to production and get a 401 Unauthorized. Or worse — it authenticates, but as the wrong user. You open the SCI trace, find the token, and stare at a wall of base64. No idea what’s inside it. No idea if it expired, if the user is wrong, if the certificate doesn’t match.
I’ve been there. So I built a tool for it.


mysapsso2-tool — paste a MYSAPSSO2 token, see exactly what’s inside. Decode, inspect, debug. Also on GitHub.

This post walks through what’s actually inside these tokens, how to forward them through SCI iFlows to authenticate against S/4HANA, and how to use the tool when things go wrong.
What’s Inside the Token
Let’s decode one. Go to mysapsso2.app.claimate.tech, paste a base64-encoded MYSAPSSO2 token, and hit Decode. Here’s what you’ll see:
User — the SAP user ID this token authenticates as (e.g. JSMITH )
System ID — the issuing system’s ID (e.g. PRD ) — not the target system. See the correction below.
Client — the issuing client number (e.g. 100 )

Creation time — the timestamp when the token was created, in UTC. ⚠
Correction: the original version of this article called this field “Validity / expiration timestamp.” It is not. SAP reads TLV field 4 as the ticket creation date and computes expiration itself as creation time + the accepting system’s login/ticket_expiration_time (default 8 hours). If you put a future timestamp here, SAP rejects the ticket with invalid format: ticket creation date / HMskiCheckValidity failed .
Signature — the PKCS#7 digital signature, including the issuer’s certificate CN, serial number, signing algorithm, and signing time
Under the hood, the token is a compact binary structure, not JSON, not XML — a custom SAP binary format:
⚠ Correction — System ID and Client identify the issuer, not the target. A token with sysid=MCP, client=100 says "this token was issued by system MCP, client 100" — your BTP application, in this pattern. The target S/4HANA system (say, CS4 ) never appears in the token at all. The ACL in the target's STRUSTSSO2 must match the issuer values. A nice consequence: the same token works on multiple SAP systems — just register the certificate and ACL entry on each target.

One thing that trips up generic ASN.1 parsers: SAP uses BER indefinite-length encoding in the PKCS#7 signature block. Standard tools like openssl asn1parse may choke on it. The mysapsso2-tool handles this correctly — it's one of the reasons I built it. Check the Help tab in the tool for a full field reference.
The Real Use Case: SCI iFlow to S/4HANA via MYSAPSSO2
This is the pattern that makes MYSAPSSO2 tokens relevant in modern integration scenarios. It’s not the standard BTP PrincipalPropagation flow (that uses X.509 certificate-based identity propagation). This is manual cookie forwarding — and it’s a perfectly valid, production-proven approach.
How the External System Creates the Token
The external system doesn’t have to be an SAP system. Any system that can perform PKCS#7 signing can create a valid MYSAPSSO2 token. This isn’t widely documented by SAP, but it’s production-proven — companies like P&G have open-sourced libraries for it, and identity providers like Nevis and Ping Federate support it natively. SAP’s own “Baking Biscuits” blog confirms: if you can sign with PKCS#7, you can bake a logon cookie.

At runtime, the external system:
Assembles the binary token: version byte, codepage, TLV fields with the target SAP user, the issuer system ID and client (identifying your application, not the target S/4), and creation timestamp (UTC, format yyyyMMddHHmmss — current time, not a future expiration)
Signs the data block with its private key using PKCS#7/CMS (detached signature, SHA-1 digest, no authenticatedAttributes — see the errata section for why) 3. Appends the 0xFF marker, 2-byte signature length, and the DER-encoded PKCS#7 block
Base64-encodes the entire binary blob
Sends it as a header in the SOAP request to SCI
For signing algorithms: DSA 1024-bit with SHA-1 has universal compatibility across all SAP NetWeaver versions. RSA works on modern S/4HANA systems running
CommonCryptoLib 8.x or later — but with two non-obvious requirements verfied in production: the certificate itself must be signed with SHA-1 (sha1WithRSAEncryption), and the PKCS#7 structure must not include authenticationAttributes. Details and working code in errata section below. The iFlow, Step by Step



Step 1: SOAP Adapter receives the request. The MYSAPSSO2 token arrives as a custom header (e.g. mysapsso2token ).
Step 2: Content Modifier sets the Cookie header. This is the critical step. You create an HTTP header:
Cookie: MYSAPSSO2=${header.mysapsso2token}
This transforms the inbound header into a proper HTTP cookie that S/4HANA will recognize.
Step 3: Body handling. The SOAP body is wrapped in the expected SOAP envelope format for the target RFC function module.

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header>
<!-- Optional header info -->
</soap:Header><soap:Body>
${in.body}
</soap:Body></soap:Envelope>
Step 4: HTTP Receiver Adapter. The outbound call goes to:
http://<webdispatcher>:<port>/sap/bc/soap/rfc?sap-client=100
Step 5: Adapter settings — this is where people get tripped up:
Proxy Type: On-Premise (routes through Cloud Connector)
Authentication: None
Location ID: Points to the Cloud Connector instance connected to your S/4 landscape
Step 6: S/4HANA validates. The system receives the MYSAPSSO2 cookie, extracts the PKCS#7 signature, checks it against the certificates imported into transaction STRUSTSSO2 , and if valid, authenticates the request as the user embedded in the token.
Why Authentication = None?
This confuses people. You’re calling S/4HANA with Authentication=None — how does that work?
Because the MYSAPSSO2 cookie IS the authentication. S/4HANA doesn’t need basic auth or client certificates from SCI. It validates the token’s PKCS#7 signature against its trust store. S/4HANA doesn’t care whether the token was issued by another SAP system or by an external identity provider — it validates purely by signature. If the signing certificate is in STRUSTSSO2 , the token is trusted.
Why This Pattern Works
The external system is a trusted token issuer — its certificate is registered in S/4’s STRUSTSSO2 ACL
SCI acts as a transparent proxy, forwarding the cookie as an HTTP header Cloud Connector handles the on-premise routing
No PrincipalPropagation needed — no X.509 certificate mapping, no BTP destination config for identity propagation
Per-request user identity — each SOAP call can authenticate as a different SAP user, because each carries its own token
S/4HANA Configuration Checklist
Issuing Side (if S/4HANA issues the token)
STRUST — System PSE has a valid key pair and certificate (DSA 1024-bit for widest compatibility)
login/create_sso2_ticket = 2 — creates logon tickets without embedding the full certificate in the token (smaller cookies, recommended for integration scenarios)
0 = disabled
1 = with embedded certificate (large tokens)
2 = without embedded certificate (compact tokens)
3 = assertion tickets only login/ticket_expiration_time = 8 — token validity in hours (adjust to your needs; shorter = more secure)
Export the signing certificate: STRUST → System PSE → Own Certificate → Export as Base64 (.crt)
Accepting Side (the S/4 receiving the token via SCI)
login/accept_sso2_ticket = 1 — required; enables acceptance of incoming SSO2 tickets (check via RZ11)
STRUSTSSO2 in client 000 — import the issuing system's (or external system's) signing certificate into the System PSE certificate list
ACL entry in the TARGET client: ⚠ this is the part everyone misses. The certificate list is managed in client 000, but the ACL is evaluated per client. If users log into client 100, the ACL entry (System = issuer SysID, Client = issuer client) must exist in client 100. The underlying table is TWPSSO2ACL (editable via SM30 ). An ACL entry only in client 000 yields: No entry in TWPSSO2ACL for SYS
<id> and CLI <client> .
ICM soft restart after STRUSTSSO2 changes — SMICM → Administration → ICM → Exit Soft → Local . Unlike STRUST for SSL, STRUSTSSO2 changes may not be picked up automatically (SAP Note 510007).
Verify: Transaction SSO2 — tests ticket generation and acceptance end-to-end;
use this to confirm the trust relationship is correctly configured
SCI / Cloud Connector Side
Cloud Connector: Virtual host mapped to S/4 system, path /sap/bc/soap/rfc allowed in the access control
No principal propagation config needed — the cookie passes through as a plain HTTP header
SCI HTTP adapter: Authentication=None , Proxy Type=On-Premise , Location ID matching your Cloud Connector
If calling via a BTP destination instead of SCI: the destination URL must point to the backend’s actual HTTP port (typically 8000), not the HTTPS port (8443). http://host:8443 silently half-works — you get a 401, and the sap-ssolist response header won't contain the certificate hash entry ( c= prefix instead of r= ), meaning SSO authentication isn't available on that endpoint.
Errata: What a Real Deployment Taught Me
The original version of this article was written from the SCI cookie-forwarding perspective. Since then I’ve deployed the issuing side in production — a CAP Node.js application on BTP generating MYSAPSSO2 tokens and calling S/4HANA (kernel 7.93, CommonCryptoLib 8.5.x) directly through a destination + Cloud Connector. Getting the token accepted took several days of ICM traces, SM50 security traces, and SICF traces. Here is everything I learned, so you don’t have to.
The certificate must be signed with SHA-1
OpenSSL defaults to sha256WithRSAEncryption . CommonCryptoLib imports such a certificate into STRUSTSSO2 without complaint — and then fails signature verification at runtime:
SsfVerify returned 5 :: SSF_API_SIGNER_ERRORS :: Error during verify - signer e SSF LIB returned 27 :: SSF_API_RECIPIENT_NOT_OK :: Operation not ok for recipie The fix is the -sha1 flag when generating the certificate:
# RSA 2048 + SHA-1 certificate (works on S/4HANA with CommonCryptoLib 8.x) openssl genrsa -out sso-private.key 2048 openssl req -new -x509 -key sso-private.key -out sso-cert.pem -days 730 \ -sha1 -subj "/C=DE/O=Example Corp/CN=my-btp-token-issuer"
# Verify — must say sha1WithRSAEncryption:
openssl x509 -in sso-cert.pem -noout -text | grep "Signature
Algorithm"
For maximum compatibility (all NetWeaver versions), DSA 1024 still works: openssl dsaparam -out dsaparam.pem 1024 openssl gendsa -out sso-private.key dsaparam.pem openssl req -new -x509 -key sso-private.key -out sso-cert.pem -days 730 \ -subj "/C=DE/O=Example Corp/CN=my-btp-token-issuer"
rm dsaparam.pem
RSA 2048 with a SHA-1 certificate is also what at least one commercial third-party SAP auth product uses in production, so this combination is well-trodden. 2. The PKCS#7 signature must NOT contain authenticatedAttributes
My first implementation included the standard authenticatedAttributes (contentType, messageDigest, signingTime). With an RSA key, CommonCryptoLib rejects this with SSF_API_SIGNER_ERRORS . Why: when authenticatedAttributes are present, PKCS#7 requires the signature to be computed over the DER-encoded attributes rather than directly over the content — and CommonCryptoLib doesn't handle that correctly for RSA (it does for DSA).
p7.addSigner({
key, certificate: cert, digestAlgorithm: forge.pki.oids.sha1,
// NO authenticatedAttributes — RSA + CommonCryptoLib requires their absenc});
Side effect: without authenticatedAttributes there is no signingTime in the signature, which SAP would otherwise use as the ticket creation date. SAP falls back to reading the creation date from TLV field 4 — which leads directly to the next point. 3. TLV field 4 is the CREATION time, not the expiration
This corrects the original article. SAP interprets tag 0x04 as the ticket creation date. If you write a future timestamp there (e.g. now + 8 hours, thinking it's an expiry), SAP rejects the token:
*** ERROR => invalid format: ticket creation date (len=14) [ssoxxlnk.c 272]*** ERROR => HMskiCheckValidity failed. [ssoxxkrn.c 1050]// WRONG — expiration:const ts = new Date(Date.now() + 8 * 60 * 60 * 1000);// RIGHT — current time = token creation time:const ts = new Date();
The accepting system computes the expiration itself: creation time + login/ticket_expiration_time (profile parameter, default 8 hours).
The digest algorithm must be SHA-1 too node-forge defaults to SHA-256 for the message digest. The SAP-side trace expects Alg=SHA1 . Set it explicitly: digestAlgorithm: forge.pki.oids.sha1 .
STRUSTSSO2: certificate in client 000, ACL in the target client
Covered in the checklist above, but worth repeating because the error is so misleading. The Certificate List lives in client 000; the ACL ( TWPSSO2ACL ) is evaluated per login client. Without an ACL entry in the client users actually log into: No entry in TWPSSO2ACL for SYS MCP and CLI 100.
*** ERROR => Neither was ticket issued by myself nor can I find issuer in TWPSS
So: import the certificate in client 000, then add the ACL entry (issuer System ID + issuer Client) in each target client. And soft-restart the ICM afterwards ( SMICM , SAP Note 510007).
Working Node.js token generator
Putting it all together — this code is verified against a production S/4HANA (kernel 7.93, CommonCryptoLib 8.5.x):
import forge from "node-forge";import fs from "node:fs";import path from "node:path";function utf16le(str) {const buf = Buffer.alloc(str.length * 2);
for (let i = 0; i < str.length; i++)
buf.writeUInt16LE(str.charCodeAt(i), i * 2);return buf;}function tlv(tag, value) {const header = Buffer.alloc(3);header.writeUInt8(tag, 0);header.writeUInt16BE(value.length, 1);return Buffer.concat([header, value]);}class SAPSSOClient {constructor() {
this.privateKey = fs.readFileSync( path.join(import.meta.dirname, "..", "certs", "sso-private.key"),
"utf8",
);
this.certificate = fs.readFileSync( path.join(import.meta.dirname, "..", "certs", "sso-cert.pem"),
"utf8",
);}createSSOToken(username, sysId = "MCP", client = "100") {// CREATION time (not expiration - SAP adds its own validity period)const createdAt = new Date();const timestamp = createdAt.toISOString()
.replace(/[-T:.Z]/g, "")
.substring(0, 14);const dataToSign = Buffer.concat([
Buffer.from([0x02]), // version 2
Buffer.from("4103", "ascii"), // codepage UTF-16LE tlv(0x01, utf16le(username)), // User tlv(0x02, utf16le(sysId)), // Issuer System ID tlv(0x03, utf16le(client)), // Issuer Client tlv(0x04, utf16le(timestamp)), // Creation timestamp tlv(0x05, Buffer.alloc(4, 0)), // Flags
]);const cert = forge.pki.certificateFromPem(this.certificate);const key = forge.pki.privateKeyFromPem(this.privateKey);const p7 = forge.pkcs7.createSignedData();
p7.content = forge.util.createBuffer( dataToSign.toString("binary")
);p7.addCertificate(cert);p7.addSigner({
key, certificate: cert, digestAlgorithm: forge.pki.oids.sha1,
// NO authenticatedAttributes - RSA + CommonCryptoLib requires it});p7.sign({ detached: true });const sigDer = Buffer.from(
forge.asn1.toDer(p7.toAsn1()).getBytes(),
"binary"
);const sigLenBuf = Buffer.alloc(2);sigLenBuf.writeUInt16BE(sigDer.length, 0);const token = Buffer.concat([
dataToSign,
Buffer.from([0xff]), sigLenBuf, sigDer,
]);return token.toString("base64");}}export default new SAPSSOClient();
Remember: sysId and client identify your application as the issuer — they must match the ACL entry in the target system's STRUSTSSO2 , and they have nothing to do with the target system's SID.
How to actually debug this on the SAP side
Ordered by usefulness, from days of trial and error:
SICF → Activate Trace on the service — the most reliable; doesn’t depend on which work process handles the request
SICF Recorder — quick overview ( LOGON_METHOD , LOGON_USER , LOGON_FAILED ) 3. SM50 → security trace level 3, then ST11 → dev_w* — detailed SSF verification errors (this is where SsfVerify returned 5 shows up)
SMICM → trace level 3 — ICM level only; does not show SSO verification details 5. SM21 — system log; may miss ICM-level rejections entirely
SSO2 transaction — configuration and signature verification
7. Postman / curl — inspect the sap-ssolist response header (base64-decode it);
entries prefixed r= mean SSO ticket auth is active on the endpoint, c= means it isn't
Relevant SAP Notes: 1055856 (SsfVerify failed — configuration for external certificates), 510007 (ICM restart after certificate changes).
Troubleshooting with the Tool
Here’s where the mysapsso2-tool earns its keep. These are the scenarios I’ve hit in production.
“401 Unauthorized from S/4HANA”
The most common issue. Grab the MYSAPSSO2 token from the SCI trace (Monitor → Message Processing → select the message → Trace → find the Cookie header). Paste the base64 value into the tool and decode it.
Check the creation timestamp first. The token expires at creation time + the target system’s login/ticket_expiration_time (default 8 hours). If the token was generated long ago — typically because the external system caches tokens — it's expired. This is the #1 cause of intermittent 401s in production. And the inverse failure mode: if the issuer wrote a future timestamp into field 4 (treating it as an expiry — the mistake the original version of this article encouraged), SAP rejects the ticket outright with HMskiCheckValidity failed .
Check the Signature section. Look at the Issuer CN and serial number. Does the issuer CN match the certificate imported into STRUSTSSO2 on the target S/4HANA system? If the external system recently rotated its signing certificate, the old cert may still be the one in S/4's trust store. Also check the certificate's signature algorithm — sha256WithRSAEncryption will import fine but fail verification ( SsfVerify returned 5 ); it must be SHA-1-signed.
If the signature and timestamp look fine, check the ACL: the token’s System ID and Client (the issuer) must have an ACL entry in STRUSTSSO2 in the client you're logging into, not just client 000. Look for No entry in TWPSSO2ACL in the trace. “Wrong User / Unexpected User”

Decode the token and check the User field. Is it the expected user, or a technical/service account? A common cause: the external system reuses a cached token from a previous session or a different user context. Each request should carry a freshly generated token for the correct user.
The System ID and Client fields identify the issuer, so don’t expect them to match the target system — but they must match the ACL entry on the target. An issuer mismatch (token says sysid=MCP, client=100 , ACL says something else) results in rejection.
“Certificate Not Trusted”
Decode the token. In the Signature section, note the Issuer CN and Serial Number. Now go to STRUSTSSO2 on the target S/4 system and compare:
Is there a certificate with that exact CN?
Does the serial number match?
Is the ACL entry correctly mapping the issuing system/client to this certificate — in the right client?
If the certificates don’t match, re-export from the issuing system and re-import. Certificate renewals are a common source of this error — the new cert has a different serial number. After any change in STRUSTSSO2 , do an ICM soft restart ( SMICM → Administration → ICM → Exit Soft → Local ) — STRUSTSSO2 changes aren't always picked up automatically (SAP Note 510007).
“Token Too Large / Cookie Rejected”
If the HTTP cookie exceeds size limits (some web dispatchers or reverse proxies cap cookies at 4KB or 8KB), check whether the token was created with login/create_sso2_ticket = 1 . This embeds the full signing certificate inside the token, making it significantly larger. Switch to = 2 to omit the embedded certificate — the accepting system will look up the certificate in STRUSTSSO2 by issuer/serial instead.
Round-Trip Testing Without S/4
Use the Encode tab in the tool to create a test token with known values — specific user, system ID, client, and creation timestamp. Then click “Decode This” to verify the round-trip. This is useful for testing your SCI iFlow’s header handling without needing a live S/4 system — you can verify that the Content Modifier correctly sets the Cookie header and that the token survives the journey through SCI and Cloud Connector intact.
Wrap-Up
MYSAPSSO2 is SAP’s legacy SSO mechanism, and yes, SAP has been pushing SAML and X.509-based authentication for years. But in the integration world — especially when third-party systems need to authenticate as specific SAP users through SCI flows — the MYSAPSSO2 cookie pattern is alive and well. It’s simpler than setting up full PrincipalPropagation with X.509 certificate mapping, and it gives you per-request user identity out of the box.
The key insight: S/4HANA validates MYSAPSSO2 tokens purely by PKCS#7 signature. It doesn’t care if the issuer is another SAP system or an external identity provider. If the signing certificate is trusted (registered in STRUSTSSO2 , with an ACL entry in the target client), the token is accepted. This makes MYSAPSSO2 a practical authentication mechanism for SCI integration flows — the iFlow just needs to forward the cookie, and S/4 does the rest.
But the devil is in undocumented details: SHA-1-signed certificates, no authenticatedAttributes with RSA, creation time (not expiry) in field 4, client-dependent ACLs, ICM restarts. None of this is in the official docs — it’s in the kernel traces. Hopefully this article saves you the days I spent there.
When something breaks — and in integration scenarios, something always breaks — you need to see inside the token. That’s what the tool is for.
mysapsso2-tool | GitHub
References
SAP Note 1055856 — SsfVerify failed; configuration for external certificates SAP Note 510007 — ICM restart after certificate changes
P&G open-source: github.com/procter-gamble-oss/mysapsso2-sp-token-adapter Mysapsso2 Principalpropagation Sso Sap Cloud Integration
Integration
MYSAPSSO2 on BTP: Principal Propagation Without PrincipalPropagation — Forwarding SSO Cookies Through SAP Cloud Integration

