If you can not get the keystore thing working maybe you'll want to try this.
Create a dedicated command line executable (.exe) which will read the web page and save the source to a text file. You can then use ColdFusion to read the file and work with the data.
Here is the ColdFusion code:
<cfscript>
_execPath = "c:/bin/clifton.exe";
_filePath = "c:/bin/clifton.txt";
// run your command-line app (clifton.exe)
cfexecute(name="#_execPath#");
// wait for the file
do {
sleep(100);
} while ( not fileExists(_filePath) )
// wait for write to finish
do {
sleep(100);
_fileInfo = getFileInfo(_filePath);
writeOutput(" ## ");
cfflush();
} while ( _fileInfo.size eq 0 || dateDiff("s", _fileInfo.lastmodified, now()) lte 3 )
writeOutput("<hr />")
_result = fileRead(_filePath);
writeDump(_result);
</cfscript>
As you can see it depends on clifton.exe
and reads clifton.txt
(clifton.txt is the result of executing clifton.exe).
How to make clifton.exe
You will use the Dart SDK and the dart2native
tool to create the executable on your development computer. You can deploy the executable on your production server as a standalone (You don't need the Dart SDK installed on production).
// clifton.dart
import 'dart:convert';
import 'dart:io';
main() {
//
const String _certFilePath = 'c:/bin/sfig2.crt.pem';
const String _responseFilePath = 'c:/bin/clifton.txt';
const String _uri =
'https://www.cliftoncameras.co.uk/all-brands-and-types-of-used-cameras/';
final File _file = new File(_responseFilePath);
final IOSink _sink = _file.openWrite();
final SecurityContext _context = new SecurityContext();
_context.setTrustedCertificates(_certFilePath);
final HttpClient _client = new HttpClient(context: _context);
saveSourceToFile(_client, _uri, _sink);
_client.close();
//
}
// get web page source then write it to file
void saveSourceToFile(HttpClient _client, String _uri, IOSink _sink) {
//
_client
.getUrl(Uri.parse(_uri))
.then((req) => req.close())
.then((res) => res.transform(Utf8Decoder()).listen((data) {
// as data is received write to file
_sink.write(data);
}, onDone: () {
_sink.close();
}));
//
}
- Download and install the Dart SDK from https://dart.dev/
- Open a terminal window and test the installation of Dart with
dart --version
(you should be able to run dart from any folder, if needed add dart to your PATH)
- In a terminal window, change directory to
c:\bin
with cd c:\bin
- Next, run
dart2native clifton.dart -o clifton.exe
- If compilation goes well you should have inside
c:\bin
the three files: clifton.dart
, clifton.exe
and the certificate sfig2.crt.pem
.
- If you wish you can test run
clifton.exe
in the terminal window, which should create the clifton.txt
file.
- Test the ColdFusion page which calls
clifton.exe
, waits for clifton.txt
then outputs the content.
If you deploy in production you need both files clifton.exe
and sfig2.crt.pem
(the certificate).
Good luck!
-Djavax.net.debug=all
and restart CF. docs.oracle.com/javase/7/docs/technotes/guides/security/jsse/… – SOSthis was working last week
What changed in between last week and this week.. updates, code changes, ..? – SOS