Phase 3: Principal Propagation Setup¶
Authenticate each MCP user to SAP with their own identity using ephemeral X.509 certificates. No shared SAP passwords. Full per-user audit trail.
When to Use¶
- Enterprise environments requiring per-user SAP authorization
- Compliance/audit requirements (who did what in SAP)
- When different users should have different SAP permissions
- Zero shared credentials architecture
Architecture¶
┌──────────────────┐ OAuth JWT ┌──────────────────────────────┐ mTLS (ephemeral cert) ┌────────────┐
│ MCP Client │ ──────────────────► │ arc1 Server │ ────────────────────────► │ SAP ABAP │
│ (IDE / Copilot) │ │ │ CN=<sap-username> │ System │
└──────────────────┘ │ 1. Validate JWT (Phase 2) │ Signed by trusted CA │ │
│ 2. Extract username │ │ STRUST: │
│ 3. Generate ephemeral cert │ │ CA cert │
│ 4. mTLS to SAP with cert │ │ CERTRULE: │
└──────────────────────────────┘ │ CN→User │
└────────────┘
Prerequisites¶
- Phase 2 (OAuth/JWT) must be configured first
- SAP admin access for STRUST, CERTRULE, ICM configuration
- OpenSSL for CA certificate generation
Step 1: Generate CA Key Pair¶
This CA signs the ephemeral certificates. SAP must trust this CA.
# Generate CA private key (RSA 2048)
openssl genrsa -out ca.key 2048
# Generate CA certificate (valid 10 years)
openssl req -new -x509 -key ca.key -out ca.crt -days 3650 \
-subj "/CN=arc1-principal-propagation-ca/O=YourCompany/C=DE"
# Verify
openssl x509 -in ca.crt -text -noout
Security: Store ca.key in a secrets manager (AWS Secrets Manager, Azure Key Vault, HashiCorp Vault). Never commit to version control.
Step 2: Configure SAP System¶
2a. Import CA Certificate into STRUST¶
- Open transaction
/nSTRUST - Double-click SSL server Standard PSE
- Switch to Edit mode (pencil icon)
- Click Import certificate (at bottom of screen)
- Paste the contents of
ca.crt(PEM format) - Click Add to Certificate List
- Save
2b. Configure ICM Profile Parameters¶
- Open transaction
/nRZ10 - Select the DEFAULT profile → Extended Maintenance → Change
- Add/verify these parameters:
| Parameter | Value | Purpose |
|---|---|---|
icm/HTTPS/verify_client |
1 |
Request client certificate (accept) |
login/certificate_mapping_rulebased |
1 |
Enable CERTRULE mapping |
- Save the profile
2c. Configure Certificate-to-User Mapping (CERTRULE)¶
- Open transaction
/nCERTRULE - Switch to Change mode
- Click Upload Certificate → import a sample ephemeral cert:
# Generate a sample cert to import into CERTRULE
openssl req -new -x509 -key ca.key -out sample.crt -days 1 \
-subj "/CN=DEVELOPER"
# Upload sample.crt into CERTRULE
- Click Rule to create a mapping:
- Certificate Entry:
Subject - Certificate Attr:
CN(Common Name) - Login As:
ID(SAP User ID) - Save
This rule means: any certificate with Subject CN = DEVELOPER → log in as SAP user DEVELOPER.
2d. Restart ICM¶
- Open transaction
/nSMICM - Go to Administration → ICM → Exit Soft (or Exit Hard)
- Wait for ICM to restart (green status)
2e. For Cloud Connector Deployments (Optional)¶
If SAP is on-premise behind BTP Cloud Connector:
- Install system certificate in Cloud Connector:
- Cloud Connector Admin UI → Configuration → ON PREMISE → System Certificate
-
Import the CA certificate (
ca.crt) -
Configure trusted reverse proxy in SAP:
-
Enable principal propagation in Cloud Connector:
- Cloud to On-Premises → system mapping → Allow Principal Propagation
- Principal type: X.509 Certificate
Step 3: Start arc1 with Principal Propagation¶
arc1 --url https://sap.example.com:44300 \
--transport http-streamable \
--http-addr 0.0.0.0:8080 \
--oidc-issuer 'https://login.microsoftonline.com/{tenant-id}/v2.0' \
--oidc-audience 'api://arc1-sap-connector' \
--pp-ca-key ca.key \
--pp-ca-cert ca.crt \
--pp-cert-ttl 5m \
--insecure # Only for testing with self-signed SAP certs
Environment Variables¶
export SAP_URL=https://sap.example.com:44300
export SAP_TRANSPORT=http-streamable
export SAP_HTTP_ADDR=0.0.0.0:8080
export SAP_OIDC_ISSUER='https://login.microsoftonline.com/{tenant-id}/v2.0'
export SAP_OIDC_AUDIENCE='api://arc1-sap-connector'
export SAP_PP_CA_KEY=/secrets/ca.key
export SAP_PP_CA_CERT=/secrets/ca.crt
export SAP_PP_CERT_TTL=5m
Note: No SAP_USER or SAP_PASSWORD needed! Authentication is entirely via certificates.
Step 4: Test¶
# Get an OAuth token
TOKEN=$(az account get-access-token --resource api://arc1-sap-connector --query accessToken -o tsv)
# Call arc1 — it will generate an ephemeral cert for your user and authenticate to SAP
curl -H "Authorization: Bearer $TOKEN" https://arc1.company.com/mcp \
-d '{"jsonrpc":"2.0","method":"tools/list","id":1}'
How It Works (Per Request)¶
- MCP client sends request with
Authorization: Bearer <jwt> - ARC-1 validates JWT signature, issuer, audience, expiry
- ARC-1 extracts SAP username from JWT claim (e.g.,
preferred_username) - ARC-1 generates ephemeral X.509 certificate:
- Subject CN = SAP username (e.g.,
DEVELOPER) - Valid for 5 minutes
- Signed by the CA key
- ARC-1 creates a per-request HTTPS client with the ephemeral cert
- SAP receives the mTLS connection, verifies the cert against STRUST
- SAP maps Subject CN to SAP user via CERTRULE
- SAP processes the ADT request as that user
- Ephemeral cert is discarded (never stored)
Troubleshooting¶
SAP Returns 401¶
- Check STRUST: Is the CA cert in the SSL Server Standard certificate list?
- Check ICM: Is
icm/HTTPS/verify_client = 1? (check via/nSMICM→ Goto → Parameters → Display) - Check CERTRULE: Does a rule mapping CN → User exist?
- Check ICM trace: Set trace level 2 in SMICM, reproduce the error, check dev_icm trace file
- Check user exists: Does the SAP user matching the CN exist and is unlocked?
Certificate Mapping Not Working¶
- Open transaction
/nCERTRULE - Upload the actual ephemeral cert (from arc1 verbose logs) to test the mapping
- Verify the rule matches
Cloud Connector Issues¶
- Check Cloud Connector logs (All/Payload trace)
- Verify
icm/trusted_reverse_proxyparameter matches CC system certificate - Ensure principal propagation is enabled in CC access control
Security Notes¶
- CA key is the crown jewel — protect it like a root password
- Ephemeral certs are valid for only 5 minutes (configurable via
--pp-cert-ttl) - RSA-2048 key pair generated per request (~2ms overhead)
- No SAP passwords stored anywhere
- Full audit trail: SAP logs show which user performed each action
- CERTRULE can restrict which usernames are allowed (not just wildcard CN mapping)
SAP Documentation References¶
- Authenticating Users Against On-Premise Systems — Principal Propagation via Cloud Connector
- Setting Up Trust Between Identity Provider and SAP — BTP principal propagation overview
- STRUST - Trust Manager (SAP Help) — Importing trusted CA certificates
- CERTRULE - Rule-Based Certificate Mapping (SAP Note 2275087) — Rule-based certificate-to-user mapping
- ICM Profile Parameters — ICM HTTPS client cert parameters
- Cloud Connector - Principal Propagation — Cloud Connector principal propagation setup