Javascript Policy httpclient.send receiving a "400 The plain HTTP request was sent to HTTPS port" response.

I'm trying to use Javascript to call a service use it's reponse to do some logic, but when I'm trying to call the service, I'm always getting this response:

"400 The plain HTTP request was sent to HTTPS port"

headers = {Authorization : "Bearer " + access_token};
     
exchange = httpClient.send(new Request("https://serviceaddress", "GET", headers));
exchange.waitForComplete();

The service I'm trying to call, is a proxy in APIGEE. What should I do?

Solved Solved
0 2 363
1 ACCEPTED SOLUTION

The "https://serviceaddress" = that's a REAL DNS name, right? TLS negotiation will work only if you use a real DNS name.

Also, have you configured the SSLInfo for your JS step?

It should look something like this:

<Javascript name='JS-doSomething' timeLimit='200' >
   <SSLInfo>
      <Enabled>true</Enabled>
      <ClientAuthEnabled>false</ClientAuthEnabled>
      <TrustStore>ref://truststoreref</TrustStore>
    </SSLInfo>
  <ResourceURL>jsc://doSomething.js</ResourceURL>
</Javascript>

Or if you want 2-way TLS, like this:

<Javascript name='JS-doSomething' timeLimit='200' >
   <SSLInfo>
      <Enabled>true</Enabled>
      <ClientAuthEnabled>true</ClientAuthEnabled>
      <KeyStore>ref://myKeystore</KeyStore>
      <KeyAlias>myKey</KeyAlias>
      <TrustStore>ref://truststoreref</TrustStore>
    </SSLInfo>
  <ResourceURL>jsc://doSomething.js</ResourceURL>
</Javascript>

View solution in original post

2 REPLIES 2

The "https://serviceaddress" = that's a REAL DNS name, right? TLS negotiation will work only if you use a real DNS name.

Also, have you configured the SSLInfo for your JS step?

It should look something like this:

<Javascript name='JS-doSomething' timeLimit='200' >
   <SSLInfo>
      <Enabled>true</Enabled>
      <ClientAuthEnabled>false</ClientAuthEnabled>
      <TrustStore>ref://truststoreref</TrustStore>
    </SSLInfo>
  <ResourceURL>jsc://doSomething.js</ResourceURL>
</Javascript>

Or if you want 2-way TLS, like this:

<Javascript name='JS-doSomething' timeLimit='200' >
   <SSLInfo>
      <Enabled>true</Enabled>
      <ClientAuthEnabled>true</ClientAuthEnabled>
      <KeyStore>ref://myKeystore</KeyStore>
      <KeyAlias>myKey</KeyAlias>
      <TrustStore>ref://truststoreref</TrustStore>
    </SSLInfo>
  <ResourceURL>jsc://doSomething.js</ResourceURL>
</Javascript>

Hi,

I've changed the real address for this before posting for disclosure reasons, but in my environment I'm using an actual address.

I didn't had configured the SSLInfo. Problem solved! Thank you very much for your attention and support!