URLConnection During Debug allow NSAllowsArbitraryLoads

I am trying to use URLConnection to get data from a device on my local network.
This device has a self signed certificate that is normally rejected by MacOS unless an exception is granted.
Access works in the various browsers (after granting the exception)

I have included a .plist in the root of the source code with:

which works fine in the compiled application.
The compiler automatically includes the data of my application.plist in the info.plist of the compiled app.

However how do I coerce the debugger to use this .plist as well?? Currently I cannot debug AND have URLConnection getting the data successfully.

Where is the problem? You can load the plist for the debugger as well as for the built app.

Thanks for your quick reply. I suspected that, however, since I do not use this environment too much, I do not know where to put this .plist so the debugger loads it as well… The compilers adds it correctly during the build phase. No problem there.
Currently I have the file located next to the project file and other sources code.

PS: using 2019.r2

Or is this a bug where the debugger should have loaded it automatically, but didn’t…

Every Mac developer has to deal with this sillyness.

You make the plist file. Then you drag-and-drop the file into the navigator. That’s it. You can get fancy and do an IDE script. Which can differ in execution between debug and build. But for the file you don’t have to do anything.

Have you checked the info.plist file of the debugged app?

That’s indeed what I already did. [quote]You make the plist file. Then you drag-and-drop the file into the navigator. That’s it.[/quote]

I now checked the info.plist file of the debug version and it does contains exactly the same info as the compiled version … So it seems that all is fine at the input end. However, execution is not the same as the compiled version…
It fails on the SSL with a message that it cannot establish a safe connection. With error number -1200 in the exception and HTTPStatusCode = 4294966096 which seems a clumsy translation of the same -1200…

Show us your code.

Two fields on the main window:

url.text = "https://eatonEasy.fritz.box" api.text = "/api/get/data?elm=MB(1)"
Button pressed on window:
(MySocket is a URLConnection).

eatonEasy = new MySocket eatonEasy.AllowCertificateValidation = false eatonEasy.send("GET",url.text+api.text)

MySocket ContentReceived:

[code]Var result As JSONItem
Var returndata as JSONItem = nil
try
result = new JSONItem(content)
Var operands as JSONItem = result.Child(“OPERANDS”)
if operands.HasName(“MBRANGE”) then
returnData = operands.Child(“MBRANGE”)
end
if operands.HasName(“MBSINGLE”) then
returnData = operands.Child(“MBSINGLE”)
end
if operands.HasName(“AORANGE”) then
returnData = operands.Child(“AORANGE”)
end
if operands.HasName(“AIRANGE”) then
returnData = operands.Child(“AIRANGE”)
end
if operands.HasName(“IRANGE”) then
returnData = operands.Child(“IRANGE”)
end
if operands.HasName(“ORANGE”) then
returnData = operands.Child(“ORANGE”)
end

if operands.HasName(“MRANGE”) then
returnData = operands.Child(“MRANGE”)
end

Window1.TextArea1.text = “”

if returndata <> nil then
if returndata.ChildAt(0).HasName(“V”) then
Var c as string = DecodeBase64(returndata.ChildAt(0).Value(“V”))
var i as Integer
Var s as String = "Response: "
for i=0 to c.Bytes-1
s = s + str(c.Middle(i,1).asc) + " "
next
Window1.TextArea1.Text = s
else
Window1.TextArea1.Text = "No V: " + content
end
else
Window1.TextArea1.text = "No Valid data received: " + content
end
Exception err as JSONException
Window1.TextArea1.Text = err.Message
end
[/code]

MySocket event Error:

Window1.TextArea1.Text = e.Message + " Code: " + str(self.HTTPStatusCode)

That’s all the code in it…

And the info.plist as generated but Xojo. The same for the build as the debug version:

[code]<?xml version="1.0" encoding="UTF-8"?>

NSAppTransportSecurity NSAllowsArbitraryLoads CFBundleExecutable eatonEasy CFBundleName eatonEasy CFBundleIdentifier com.astsoftware.eatoneasy CFBundleInfoDictionaryVersion 6.0 CFBundleVersion 1.0.0.0.0 CFBundleDevelopmentRegion nl CFBundlePackageType APPL CFBundleSignature ???? NSHumanReadableCopyright CFBundleShortVersionString CFBundleIconFile App LSMinimumSystemVersion 10.10.0 NSHighResolutionCapable CFBundleSupportedPlatformsMacOSX [/code]

Are you code-signing your app?

No, this is just to debug it. The compiled/built version communicates fine via the SSL connection.
The debug version not. It refuses to setup the connection as if the .plist exception is not defined.

PS: running on latest Mojave release

Ahum
I found the problem: I had a breakpoint activated just after the send thus before the URLConnection was able to do its job… Hence the interaction failed because the process was stuck on the breakpoint.

Putting the breakpoint where it makes sense, resolves the issue.

Sorry for the wasted time.

Hans