Skip to main content
Participant
May 28, 2015
Question

how to access https site from javascript socket object

  • May 28, 2015
  • 2 replies
  • 3936 views

HI ,

I'm new to SSL's and scripting.

I have written code to access http site and it is working.Below is the code.The script is failing when i try to access https application.

Can some one please help me .

below is the code.

var request = [];

    request.push('POST', ' ', path, ' ', "HTTP/1.1\n");       

    request.push('Authorization:', 'Basic d2NhZG1pbjp3Y2FkbWlu==', '\n');

    request.push('Host: ', host, "\r\n");

    request.push('User-Agent: ', USER_AGENT, "");

    //request.push('Connection: ', 'close', "\n");

    request.push('Pragma: ', "no-cache", "\r\n");

    request.push('Accept: ', "*/*", "\r\n");

    request.push('Accept-Charset: ', "UTF-8", "\r\n");

    request.push('Accept-Language: ', "en-US", "\r\n");

    request.push('Content-Language: ', "en-US", "\r\n");

    request.push('content-location: ', file.name, "\r\n");

    //request.push('Content-Length: ', fileContents.length, "\r\n");

    request.push('Content-Length: ', content.length, "\r\n");

    request.push('Content-Type: ', 'multipart/form-data;boundary=', boundary, "\r\n");

    

    request.push('\n');

    request.push(content);       

      alert('request--->'+request); 

    //  5. Upload

    var socket = new Socket;   

    socket.open(host+':80', 'BINARY');

    for (var i = 0; i < request.length; ++ i) {

        socket.write(request);

    }

This topic has been closed for replies.

2 replies

Participant
June 5, 2015

Hi Ten,

Thanks for your time.

Sorry I'm confused totally .Let me rephrase the issue im facing.

I'm executing the script from AI.The script starts Bridge and connects to the external application(Once connected takes input as AI file and send request  request  in Socket object) .

This is working for http .failing when i try to access https.

Is there any way to implement https access in the script it self without modifying in external Server.Seems Adobe Extension SDK with this ,i have to re-Implement totally.

Please suggest I need something which can be executed from AI .

Regards,Venkat

Ten A
Community Expert
Community Expert
June 8, 2015

We can write HTTPS Socket logic with Extendscript and Bridgetalk, Need to impliment  "Handshake encripted stream" > "Build HTTP headder" > "encrypt with private key" > "pass encrypted headder" > "build body and encrypt"...

Its very bother for me. I often to use Adobe Extension SDK like previouse case.

However, you can read as reference HTTP over TLS:

http://www.infoq.com/articles/HTTPS-Connection-Jeff-Mose

In AdobeExtensionSDK, We can impliment HTTPS process with node.js and NPM packages, and main logic(working with Illustrator Objects) still Extendscript. You only need to rewrite socket manipuration and its very easy in NODE.js.

Ten

Ten A
Community Expert
Community Expert
May 28, 2015

Unfortunately, Illustrator not supported Socket Object.


Ten

Participant
June 3, 2015

HI Ten,

Thanks for responding.

I'm using bridge and able to access http URL.the moment i access https it is breaking.

Do we have any work around or solution to access https URL.

Please help .

Regards.

Venkat

Ten A
Community Expert
Community Expert
June 4, 2015

You need to implement TLS, Can find some solutions in GitHub.

However, We can use Adobe Extension SDK, Provide to make Extensions HTML5+NODE.js with Extendscript. NODE.js includes HTTPS protocol and easy to use. You can reference below:

Adobe-CEP/CEP-Resources · GitHub

Ten