Skip to Content

PROBLEM consuming On-premise external services with latest CAP update

Hi, everybody,

With the last CAP update (4.1.7) the On-premise external services I was using start giving the following error:

<error xmlns="http://docs.oasis-open.org/odata/ns/metadata">
<code>ERR_TLS_CERT_ALTNAME_INVALID</code>
<message>
Hostname/IP does not match certificate's altnames: Host: localhost. is not in the cert's altnames: DNS:www.xxxxxxxxxxx.com.mx, DNS:xxxxxxxxxxx.com.mx
</message>
</error>

My configuration of the external service in the package.json:

"Z_OD_SCP_CORE_0001_SRV": {
        "kind": "odata",
        "model": "srv/external/Z_OD_SCP_CORE_0001_SRV",
        "credentials": {
          "destination": "Z_OD_SCP_CORE_0001_DEST",
          "requestTimeout": 30000
        }
      }

My service CDS (srv/Z_OD_SCP_CORE_0001_SRV.cds)

using {Z_OD_SCP_CORE_0001_SRV as external} from './external/Z_OD_SCP_CORE_0001_SRV.csn';

service CoreService {
    @readonly
    entity Sociedades as projection on external.SociedadSet;
}

Finally (srv/Z_OD_SCP_CORE_0001_SRV.js)

const cds = require('@sap/cds');

module.exports = cds.service.impl(async function () {
  const { Sociedades } = this.entities;
  const extSrv = await cds.connect.to('Z_OD_SCP_CORE_0001_SRV');

  this.on('READ', Sociedades, (req) => extSrv.tx(req).run(req.query));
});

Before the update this service was working perfect, but now it doesn't work. When I returned to version 4.1.5 it still stopped working normally, and started throwing me the following message:

<error xmlns="http://docs.oasis-open.org/odata/ns/metadata">
<code>500</code>
<message>Request failed with status code 404</message>
</error>

To solve this error I had to modify my original code in this way:

const cds = require('@sap/cds');

module.exports = cds.service.impl(async function () {
  const { Sociedades } = this.entities;
  const extSrv = await cds.connect.to('Z_OD_SCP_CORE_0001_SRV');
  const { SociedadSet } = extSrv.entities;

  this.on('READ', Sociedades, (req) => extSrv.tx(req).run(SELECT.from(SociedadSet)));
});

Doing a little research, I realized the following, doing some cosole.log:

Getting back to CAP 4.1.5 version, the code that previously worked, printing the CQN, i got this: (THIS IS NOT WORKING NOW)

  this.on('READ', Sociedades, (req) => {
    console.log(req.query);
    return extSrv.tx(req).run(req.query);
  });
[cds] - server listening on { url: 'http://localhost:4004' }
[ terminate with ^C ]

GET /core/Sociedades
{ SELECT: {
  from: {ref:['CoreService.Sociedades']},
  columns: [ {ref:['Bukrs']}, {ref:['Butxt']}, {ref:['Sort2']} ],
  orderBy: [ {ref:[ 'Bukrs' ], sort: 'asc' } ],
  limit: { rows: {val:1000} }
}}

with the change a made (THIS IS ACTUALLY WORKING)

  this.on('READ', Sociedades, (req) => {
    console.log(SELECT.from(SociedadSet));
    return extSrv.tx(req).run(SELECT.from(SociedadSet));
  });
[cds] - server listening on { url: 'http://localhost:4004' }
[ terminate with ^C ]


GET /core/Sociedades
{ SELECT: {
  from: {ref:['Z_OD_SCP_CORE_0001_SRV.SociedadSet']},
  columns: [
    {ref:[ 'Bukrs' ], as: 'Bukrs' },
    {ref:[ 'Butxt' ], as: 'Butxt' },
    {ref:[ 'Sort2' ], as: 'Sort2' }
  ]
}}

Notice the difference in the from property of the query.

This es the version of my libraries that I actually have:

cds --version 
@sap/cds: 4.1.5
@sap/cds-compiler: 1.35.0
@sap/cds-dk: 2.0.8
@sap/cds-foss: 2.0.0
@sap/cds-odata-v2-adapter-proxy: 1.4.42
@sap/cds-reflect: 2.12.2
@sap/cds-runtime: 2.1.7
@sap/cloud-sdk-core: 1.17.2
@sap/hana-client: 2.5.105
@sap/xsenv: 3.0.0
@sap/xssec: 3.0.9
Node.js: v12.18.3

Thanks in advance

Add a comment
10|10000 characters needed characters exceeded

  • Hi,

    You mentioned that you use @sap/cds 4.1.7. but your screenshot shows version 4.1.5. Could you please try it again with the latest version 4.1.7?

    Best regards,
    Iwona

  • Hi Iwona,

    With @sap/cds 4.1.7 I got the following error:

    <error xmlns="http://docs.oasis-open.org/odata/ns/metadata">
    <code>ERR_TLS_CERT_ALTNAME_INVALID</code>
    <message>
    Hostname/IP does not match certificate's altnames: Host: localhost. is not in the cert's altnames: DNS:www.xxxxxxxxxxx.com.mx, DNS:xxxxxxxxxxx.com.mx
    </message>
    </error>

    Then I get back to 4.1.5 but I'm getting this message:

    <error xmlns="http://docs.oasis-open.org/odata/ns/metadata">
    <code>500</code>
    <message>Request failed with status code 404</message>
    </error>

    I had to fix it like a say before in my post, that is the reason my screenshots are with @sap/cds 4.1.5

    Best regards,

Related questions

1 Answer

  • Posted on Sep 04 at 12:36 PM

    Hi Luis,

    Should be fixed with cds 4.1.9. Could you please check it?

    Best regards,

    Olena

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.