lb4 datasourcelb4 openapi --client pointing to datasourceI get following exception:
Unhandled error in GET /user/8f9d1e34-c340-4ebe-af11-fa0c4575f676: 500 FetchError: request to https://localhost:8243/scim2/1.0.0/Users/8f9d1e34-c340-4ebe-af11-fa0c4575f676 failed, reason: unable to verify the first certificate
at ClientRequest.<anonymous> (D:\DEV_BTC\GIT\Foton\PIX\application\composite-services\perfil-usuario-ms\node_modules\node-fetch\lib\index.js:1461:11)
at ClientRequest.emit (events.js:315:20)
at TLSSocket.socketErrorListener (_http_client.js:426:9)
at TLSSocket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
For SOAP and REST Connector there is a parameter to handle self-signed certificate called strictSSL: false. How about OpenAPI Connector? Is there any workaround? Should I turn this issue to feature request?
Thank you!
@emiliobristech loopback-connector-openapi uses node-fetch behind the scenes. You can configure the datasource settings with agent property per https://www.npmjs.com/package/node-fetch#custom-agent.
Hi again @raymondfeng thank you for you help! I found some references abou adding property rejectUnauthorized=false to agent configuration but it doesn't work. Here is my DS:
const config = {
name: 'wso2Scim2Api',
connector: 'openapi',
spec: './src/openapi-client/wso2-scim2-api.json',
validate: true,
authorizations: {
default:
"<API_KEY>",
},
positional: true,
debug: true,
agent: {
rejectUnauthorized: false,
}
};
Is my configuration correct?
You need to create an instance of https.Agent:
```ts
import https from 'https';
const config = {
name: 'wso2Scim2Api',
connector: 'openapi',
spec: './src/openapi-client/wso2-scim2-api.json',
validate: true,
authorizations: {
default:
"<API_KEY>",
},
positional: true,
debug: true,
agent: new https.Agent({
rejectUnauthorized: false,
}),
};
You need to create an instance of https.Agent:
import https from 'https'; const config = { name: 'wso2Scim2Api', connector: 'openapi', spec: './src/openapi-client/wso2-scim2-api.json', validate: true, authorizations: { default: "<API_KEY>", }, positional: true, debug: true, agent: new https.Agent({ rejectUnauthorized: false, }), };
I did exactly what you suggested but it doesn't work. Got same exception. What else could it be?
Thanks!
@emiliobristech I just fixed loopback-connector-openapi to allow such options, please upgrade to [email protected] and use the following config:
You need to create an instance of https.Agent:
import https from 'https';
const config = {
name: 'wso2Scim2Api',
connector: 'openapi',
spec: './src/openapi-client/wso2-scim2-api.json',
validate: true,
authorizations: {
default: "<API_KEY>",
}
positional: true,
debug: true,
httpClientOptions: {
agent: new https.Agent({rejectUnauthorized: false}),
}
};
See https://github.com/strongloop/loopback-connector-openapi#customize-httphttps-client
@emiliobristech I just fixed
loopback-connector-openapito allow such options, please upgrade to[email protected]and use the following config:You need to create an instance of https.Agent: import https from 'https'; const config = { name: 'wso2Scim2Api', connector: 'openapi', spec: './src/openapi-client/wso2-scim2-api.json', validate: true, authorizations: { default: "<API_KEY>", } positional: true, debug: true, httpClientOptions: { agent: new https.Agent({rejectUnauthorized: false}), } };See https://github.com/strongloop/loopback-connector-openapi#customize-httphttps-client
Hey @raymondfeng, now it works perfectly! Thank you and have a good day!
Most helpful comment
@emiliobristech I just fixed
loopback-connector-openapito allow such options, please upgrade to[email protected]and use the following config:See https://github.com/strongloop/loopback-connector-openapi#customize-httphttps-client