Is It possible to configure SSL Information using Java Script in .js file

Not applicable

To hit a service which is https we need to set the below information in the TargetEndpoint

<SSLInfo> <Enabled>true</Enabled> <ClientAuthEnabled>true</ClientAuthEnabled> <KeyStore>myKeystore</KeyStore> <KeyAlias>myKey</KeyAlias> </SSLInfo>

Now I want to hit the service using get() method in my .js(JavaScript) resource

for example:

httpClient.get("https://www.example.com");

Because my backend is using https I want to configure my ssl information using Javascript (In my .js file)

Is it possible to set the KeyStore and KeyAlias using Java Script.If it is yes then please let me know how can we achieve that

0 6 1,861
6 REPLIES 6

Not applicable

@Kumar

You might be conflating TargetEndpoints with the services accessible though the javascript httpClient. I don't think the Apigee httpClient interface is configured by either the TargetEndpoint/HTTPTargetConnection/SSLInfo/.. nor the ServiceCallout/HTTPTargetConnection/SSLInfo.. elements.

There is a class of API Proxies which predominately call back end services. These proxies define and use both ProxyEndpoints and TargetEndpoints request and response message flows. You can see the TargetEndpoint orientation in the message flow here <http://apigee.com/docs/api-services/reference/api-proxy-configuration-reference>

The TargetEndpoint/HTTPTargetConnection/SSLInfo/... elements set transport details for the TargetEndpoint HTTP Service. Look for more information <http://apigee.com/docs/api-services/content/configuring-ssl-edge-backend-service>

You might consider hitting your service directly from a Service Callout Policy. The Edge Message Processor is optimized to deal with service call outs made from the Service Callout Policy.

This ServiceCallout/HTTPTargetConnection/SSLInfo/... describes the transport used for the service callout request. Look for more information here <http://apigee.com/docs/api-services/reference/service-callout-policy>

<ServiceCallout async="false" continueOnError="false" enabled="true" name="Service-Callout-Example"> <DisplayName>Call My Example Using 2 Way SSL</DisplayName> <Request clearPayload="true" variable="myRequest"> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> </Request> <Response>calloutResponse</Response> <Timeout>60000</Timeout> <HTTPTargetConnection> <URL>https://www.example.com</URL> <SSLInfo> <Enabled>true</Enabled> <ClientAuthEnabled>true</ClientAuthEnabled> <KeyStore>myKeystore</KeyStore> <KeyAlias>myKey</KeyAlias> </SSLInfo> </SSLInfo> <Properties/> </HTTPTargetConnection> </ServiceCallout>

Not applicable

Thank for your reply jbeninghaus

What you said I understood.

But Whats my exact requirement is I have to call a third party service using java script .And Its not my target endpoint.I have to hit the 3rd party service and I have use the response which is coming from the 3rd party service to hit the target back end.

Now coming to my task ,Now I have to hit the 3rd party service from my java script.

It is a https service .so is it possible to specify my SSLInfo of that service using Java Script

Not applicable

In short whats my requirement is I want to hit a service which is https from my java script (.js)file.Is it possible to provide the SSLInfo there?

Not applicable

@Kumar

It is not possible to specify the SSLinfo attributes such as keystore in the javascript or Node.js as of today.

Not applicable

@Kumar - My understanding is that you want to leverage JS policy to make HTTPs calls to and API or Web Service secured with SSL/TLS Client Authentication. Based on the answers above this is not supported yet on JS. So, my answer won't change that fact, however I wanted to document in this thread it is also possible to leverage Node.js SSL/TLS Client Authentication, so developers are aware of choices available to them. If you're interested in learning how to implement it, you can follow this tutorial and implement it in Apigee with a Node.js API Proxy. Current code written in a JS Policy can still be leveraged to be executed in Node.js.

More documentation about handling outgoing requests in Apigee Node.js can be found here.

Hope it helps!

SSLInfo can be set in for js callouts / httpClients as well. The configuration will be same for all instances.

<Javascript timeLimit="200" name="Js-Callout">
  <DisplayName>Js-Callout</DisplayName>
  <Properties>
  </Properties>
  <SSLInfo>
    <Enabled>true</Enabled>
    <ClientAuthEnabled>true</ClientAuthEnabled>
    <KeyStore>myKeyStore</KeyStore>
    <KeyAlias>myKeyAlias</KeyAlias>
    <KeyAlias>keyStore</KeyAlias>
  </SSLInfo>
  <ResourceURL>jsc://callout.js </ResourceURL>
</Javascript>

https://docs.apigee.com/api-platform/reference/policies/javascript-policy#SSLInfo