SKP 2017 Launching external .exe making https calls

Hello all :o)

I have a problem with my extension on Sketchup 2017.
(It works perfectly on all previous Sketchup version i have)

It seem’s i cannot anymore launch an external application from the Ruby API or from an external C dll (.so).
Is there a new restriction on that in 2017 ? Maybe because my extension is not yet registered ?

I can launch a very simple application showing a simple message box.
I can launch it using my external C code and directly from Ruby via the system(xxx) call.

But my Application cannot be launched from within SKP 2017.
Of course i can launch it directly (double clic) and i can launch it via the Cmd line. I can also launch it form other CAO applications like Archicad, Revit, 3D Studio…

I have inactivated AVAST wich can give some strange things sometimes.

Really strange :o)

Thank’s a lot for any suggestion.

Georges

Can you reveal how you tried it?
The following works for me:

  • `/path/to/firefox` (same as: %x{/path/to/firefox})
  • system("/path/to/firefox")

Yes of course…

            cmd_line="\"C:/Program Files/Client/Folder/MyApp.exe\" \"fr\" \"Sketchup\" \"2017\" \"csv\" \"basic\" \"download\" \""
            system(cmd_line)

This works perfectly when i launch a simple app at the same place, with the same name etc…

Some new tests (even more strange to me) :slight_smile:

In my Application i have put a simple dialog (message box) at the startup.
When i launch it from Sketchup 2017 it is launched because i see this message box.
But after that message box is dismissed…the application simply quit’s it self.

For me it seem’s that as soon i made a network request in my application, it stops.
(but i tell again that it works perfectly from SKP 2016, from command line, by double clicking it, from Revit etc… so i’m quite sure my App is OK)

I have made another test :slight_smile:

I built a little application that does the following:
1°/ Show a startup message box
2°/ Do a network request (calling a webservice at a https://xxx adress)
3°/ Show a end message box

If I launch this application as standalone or from cmd line or from another application or from Sketchup 2016 : no problem, it works.

When i launch this application from SKP 2017 it shows the first message box and then it quits (where ? how is that possible ?)

When i change the code in this little application for using the same webservice on a http://xxx adress it works from SKP 2017. Startup message, calling the WS, end message and correct quit at end.

So my conclusion (for now) is that an application launched from SKP 2017 can’t do https:// requests.
How is that possible ? :open_mouth:

SU 2014 - 2016 ran Ruby 2.0.0-p247.

SU 2017 runs Ruby 2.2.4-p230.

Thanks Dan :slight_smile:

But what do you mean with that answer ?

My external application is a C++ app and has no link with SKP or Ruby.
It is launched from Ruby via a system(xxx) call or (with same results) over an external C code (compiled as .so dll).

You asked how there could be a difference. I’m showing you one of the differences.

Is your application running in it’s own process when executed via system() ?

So, go to the Ruby code for the various versions, and see if there has been any changes to the system() method “under the hood”.


If this is not SketchUp specific, then perhaps ask in the Ruby core forum:

or perhaps:

Here’s another test you can make:

Install the same version of stand-alone Ruby as embedded in SketchUp (2.2.4 in SketchUp 2017).
Strip out the part of your code that attempts to launch your app.
Try running that extract using the stand-alone Ruby and see what happens. If it also fails, there is some issue with Ruby 2.2.4. If it runs ok, then we are back to SketchUp.

Because it runs as an embedded process that has no standard input and output and also to handle a few compatibility issues, I believe the Ruby interpreter embedded in SketchUp is slightly “tweaked”. But I don’t know why that would cause what you are seeing.

Thanks Dan and Steve.

I’ll try what you suggest Steve.
I’ll post the results here.
(not before beginning of next week i suppose)

Hi forum :slight_smile:

Sorry for this long delay, i was in a hurry on the Revit and Archicad part of my project so i did’nt work on the Sketchup part.

I have tried my code in Ruby 2.2.4 and it works perfectly.
So i suppose Sketchup 2017 is “blocking” something.

You might double check the environment, etc. Also, how your exe is finding any cert files. The following works for me using 2017 –

`c:/ruby25_64/bin/ruby -e "require 'net/http' ; File.open('E:/test.txt', 'w') { |f| f.write Net::HTTP.get(URI('https://www.google.com/index.html')) }"`

I’ve got a little different ruby install, but I doubt that makes a difference…

FYI, SketchUp (since v2015,)
sets a variable within it’s copy of the environment thus:

"SSL_CERT_FILE"=>
  "C:/Program Files/SketchUp/SketchUp 20nn/Tools/RubyStdLib/platform_specific/cacert.pem"

where nn is the year of release.

This applies only to loading “net/http” within SketchUp’s Ruby process.


Also, all versions of SketchUp that came with RubyGems,
have a “ssl_certs” sub-directory, beneath the “rubygems” directory.

Sketchup.find_support_file("Tools/RubyStdLib/rubygems/ssl_certs")
# returns this string (for SketchUp 2016):
"C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/ssl_certs"

There are 5 certificates in this directory.

Dan,

This applies only to loading “net/http” within SketchUp’s Ruby process.

A discussion of processes is probably outside of the scope of this forum. What is important is the environment in place when an external command is executed in SU. I am speaking only about Windows, if anyone (Dan?) can test these issues with OSX, it would be appreciated.

I’ve attached three files:

  1. info_dump.rb generates output for two below files.

  2. info_dump_ruby_from_su.txt - generated by stand-alone ruby install run from the SU Ruby Console.

  3. info_dump_ruby.txt - generated by stand-alone ruby.

So, regarding your phrase ‘This applies only to’, you’ll notice that the environment that is passed to stand-alone ruby run from SU is not the same as the environment when run outside of SU. In particular, ENV[‘SSL_CERT_FILE’] is set to the SU location.

Hence, any apps shelled out to from ruby in SU do not receive an environment that is the same as if they were run stand-alone.

BTW, if you’re aware of the cert file, why was SU2017 released with one dated 2014-09-03? Of course, we won’t even talk about the version of OpenSSL, etc.

info_dump_ruby_from_su.txt (3.5 KB)
info_dump_ruby.txt (3.3 KB)
info_dump.rb (2.4 KB)

Below is the ‘Native Ruby’ section of what I’m currently using in SU2017:

-------------------------------------------------------------------- Native Ruby
ruby 2.3.5p310 (2017-05-01) [x64-mingw32]

Gem::VERSION     2.5.2
DBM::VERSION     GDBM version 1.10. 13/11/2011 (built Apr  3 2017 16:32:08)
GDBM::VERSION    GDBM version 1.10. 13/11/2011 (built Apr  3 2017 16:32:08)

OpenSSL::VERSION              1.1.0
    OPENSSL_VERSION           OpenSSL 1.0.2k  26 Jan 2017
    OPENSSL_LIBRARY_VERSION   OpenSSL 1.0.2k  26 Jan 2017

Psych::VERSION                2.1.0          LIBYAML_VERSION  0.1.7
Readline::VERSION (ext)       7.0
Zlib::ZLIB_VERSION            1.2.11

Socket                        Ok
Win32::Registry               Ok
WIN32OLE                      Ok

From initial testing (more to come) everything works fine. In case you’re wondering, OpenSSL 1.1.0 will only work with Ruby 2.4+. And, 2.4+ will not work with SU due the Integer issue.

But, since 2.3 works with SU, it would allow plug-in devs to start testing with # frozen_string_literal: true. There’s also 147 warnings generated by code included with SU…

Ruby v2.2 - trunk docs

Yea, and why I pointing toward StackOverflow (above.)

It was just an offhand FYI kind of post.

I also as I do not do Mac.

Like most processes, they get a copy of the parent’s environment.

So, from SketchUp’s console do this:

puts %x{set}.split("\n")

… and you’ll see it is the same as SketchUp’s ENV pseudo-hash.


ADD:

Why are telling me I why I wrote something ? I know why I wrote it.
And have been familiar with the system environment since DOS 2.

I think we are saying the same thing in different ways here. We seem to be typing at the same time, and “passing in the night” so to speak.

Dan,

Re RubyGems certs, they are only used for gem installation. OpenSSL does not use them unless you specifically write code to do so.

1 Like

Dan,

Why are telling me I why I wrote something ? I know why I wrote it.

Well, I felt your phrase -

This applies only to loading “net/http” within SketchUp’s Ruby process.

seems to imply that SSL_CERT_FILE has no affect outside of local “net/http” (actually, anything using OpenSSL and the default cert chain, so most of the ‘net’ libraries).

You have since clarified that.

1 Like

One of the SketchUp team members talks about OpenSSL issues with current versions of SketchUp and advises using a different course:

Georges,

Although it was followed with many other posts, I believe my original post showed that that SU is not in any way blocking external apps from using SSL. I haven’t used OpenSSL (openssl.exe) for a while (not Ruby OpenSSL), but if you’d like I could try to verify a server with it from within SU…

Hi all,

Many thanks for all your replies.

I’m not on my working computer so i can’t make tests now.
But friday evening i found out that there is something bad with (my ?) OpenSSL.
I changed the method of calling my .exe by using wsscript and so i could see an error message box appear…what i have never seen before by calling the .exe via system(…) or via extern C code. :slight_smile:

I’ll give you all details tomorrow, but before i prefer to redo my tests and confirm what i have seen.

Georges