401 Unauthorized with Basic Authentication via Cloud Connector
This page is for BTP and SAP Basis administrators. It explains why a BTP destination with Basic Authentication can get 401 Unauthorized from an ABAP system behind SAP Cloud Connector although the user and password are correct, and how to fix it without breaking single sign-on.
Symptoms
Section titled “Symptoms”- Calls from Skybuffer AI to the ABAP system fail with
Request failed with status code 401, for example Run Replication in Data Source Management. - The destination in the BTP cockpit has Authentication
BasicAuthenticationand Proxy TypeOnPremise. The user exists in the right client, is not locked and has a productive password. - The same user and password work when you call the same OData service directly, from a browser or with
curl. - The ABAP system shows no logon attempt for this user, not even a failed one.
- The Cloud Connector trace shows that the request reaches the ABAP system.
The Cloud Connector system mapping that the destination uses is set up for principal propagation:
- Principal Type is
X.509 Certificate. - System Certificate for Logon is selected.
On its HTTPS port, the ABAP system asks every client for a certificate (profile parameter icm/HTTPS/verify_client = 1, the default) and trusts the Cloud Connector system certificate (profile parameters icm/HTTPS/trust_client_with_issuer and icm/HTTPS/trust_client_with_subject). So the ABAP system handles every request that comes through this mapping as principal propagation. A Basic Authentication request carries no propagated user, so the system answers 401 and never checks the user and password in the Authorization header.
SAP describes this behavior in SAP Note 3012115.
Solution
Section titled “Solution”Do not change the existing mapping: destinations that use single sign-on need it. Add a second mapping without principal propagation for technical users that log on with user and password, and point the destination to it.
Step 1. Add a system mapping without principal propagation
Section titled “Step 1. Add a system mapping without principal propagation”Step 1. In the Cloud Connector administration, select your subaccount, open Cloud To On-Premise → Access Control, and click + in Mapping Virtual To Internal System.
Step 2. Fill in the wizard:
- Back-end Type:
ABAP System - Protocol:
HTTPS - Virtual Host: a new name that no other mapping uses, for example
erp-basic.example.com - Virtual Port: the same port as in the existing mapping, for example
443 - Internal Host and Internal Port: the same as in the existing mapping
- Principal Type:
None - System Certificate for Logon: not selected
- Host In Request Header:
Use Internal Host - Check Internal Host: selected
Step 3. Click Finish. The Check Result of the new mapping shows Reachable.
Step 4. Select the new mapping and click + in Resources Of …. Enter URL Path /, choose Access Policy Path And All Sub-Paths, and click Save. If your security policy requires it, expose only the service paths the destination calls instead of /.
Step 2. Point the destination to the new mapping
Section titled “Step 2. Point the destination to the new mapping”Step 1. In the BTP cockpit, open your subaccount → Connectivity → Destinations, select the destination and click Edit.
Step 2. In URL, replace only the host with the virtual host of the new mapping. For example, http://erp.example.com:443/sap/opu/odata/... becomes http://erp-basic.example.com:443/sap/opu/odata/.... Keep the authentication, user, password and Location ID as they are.
Step 3. Click Save, then repeat the call that failed, for example Run Replication in Data Source Management. It now completes without the 401 error.