'Unspecified certificate from client' error received from Delphi THTTPClient post request in ver 10.3.1 but not 10.3.2 - json

As the title suggests, I'm receiving this error when trying to make a simple POST request via a THTTPClient in Delphi and the connection isn't completed so I get no response:
lHttpResp := FHTTP.Post(
'https://url123/',
jsonToSend,
nil,
[
TNetHeader.Create('content-type', 'application/json;charset=utf8'),
TNetHeader.Create('accept', 'application/json;charset=utf8')
]);
This call works without an issue when built with Delphi 10.3.2 / Windows 10.
I thought perhaps copying the 10.3.2 \Embarcadero\Studio\20.0\source\rtl files to the 10.3.1 machine might have done the trick, alas it didn't.
Upgrade is an option, however it would be nice if there was a simple code fix/work around for 10.3.1.
Edit: I thought this might help, however it didn't: Unspecified certificate from client when using TRESTRequest
How do I get this working in 10.3.1?

The solution is to just upgrade to a version >= 10.3.2

Related

MediaWiki, trying to investigate VisualEditor "Error contacting the Parsoid/RESTBase server (HTTP 500)"

A lot of people have the same error for many different reasons, so, after trying a composer update, I've tried to investigate it starting from the browser and reconstructing step by step what is happening. It's really hard for me and I would really appreciate help from a PHP Developer!
From Chrome Developer Tools I could find the Ajax request in the background and the called url on the server
By playing with the url I realized that changing the action name returned a different error code, which let me understand that the current call is just a generic API in the middle between the browser and whatever is "apierror-visualeditor-docserver-http"
The Ajax call
{mysite}
/ api.php
? action=visualeditor
& paction=parse
&page=Cosa_c%27%C3%A8_da_fare%3F
Example
https://www.tematichedigenere.com/api.php?action=visualeditor&paction=parse&page=Cosa_c%27%C3%A8_da_fare%3F
The response from the Ajax call
The serverside call to rest api
Then I can see from the Apache server's log that the api page contacts the following url (returning 500)
GET
//rest.php/
{mywebsiteurl}
/v3/page/html/
Cosa_c%27%C3%A8_da_fare%3F/27246
?redirect=false
&stash=true
example
"GET //rest.php/www.tematichedigenere.com/v3/page/html/Cosa_c%27%C3%A8_da_fare%3F/27246?redirect=false&stash=true HTTP/1.0" 500 5621 "-" "VisualEditor-MediaWiki/1.38.2"
Another example of log (returning 404)
{an IP} - -
[04/Dec/2022:14:16:12 +0000]
"POST
/rest.php/
{mywebsiteurl}/v3
/transform/html/to/wikitext
/Riflessioni_sulla_sessualizz._femm._collegate_-_bozza%2Fprova
HTTP/1.0"
404
467
"-"
"VisualEditor-MediaWiki/1.38.2 X-Middleton/1"
Maybe the initial double / is wrong?
Anyway if I call the uri directly from my browser https://tematichedigenere.com/rest.php/www.tematichedigenere.com/v3/page/html/Cosa_c%27%C3%A8_da_fare%3F/27246?redirect=false&stash=true
The server does a antirobot check but I'm not sure that was the problem.
I've realized that the 500 error code hides a more complex real error which is returned by accessing directly the url from the log.
As you say, the visualeditor API is mostly just a proxy to the Parsoid API. The double / is wrong (check your $wgVirtualRestConfig settings maybe), I don't think it actually matters though. The error sounds like you are using incompatible library versions - make sure MediaWiki core and the VisualEditor extension are for the same release, and that the parsoid Composer library is up to date.
Update from OP:
the issue was solved. I simply had to delete the folder /vendor/wikimedia/parsoid and copy it from the fresh install. I couldn't see there were disalignment because of a problem in the compare tool. I got a lot of help in the IRC channel (not in Phabricator and not in Mediawiki forums, it seems IRC is really helpful for MW products).

Laravel - Json Encode Works Fine But Returns Malformed UTF-8 Error Regardless

Problem
The JSON is returned correctly encoded but json_last_error equates to 5 thus Laravel throws this exception on response creation in JsonResponse->setData().
Related References
A resolved bug report for symfony and PHP 7.3: https://github.com/symfony/symfony/issues/31447 mentions this exact issue. That is:
If a json_encode()/json_decode() without JSON_THROW_ON_ERROR encoding option set throws an error, any subsequent call to the same with that flag set will not reset the error of the previous call.
The JSON_THROW_ON_ERROR RFC mentions this behavior as by design: https://wiki.php.net/rfc/json_throw_on_error
Unfortunately Laravel's code uses the flag but does not cater for this behavior and throws exception if json_last_error() returns a non zero value. Which in this case should have been ignored as it will always reference the previous error. Perhaps a version check should be added.
Investigation
I have also searched the bowls of my application and haven't found the misbehaving json_encode/json_decode without JSON_THROW_ON_ERROR set so I am sure it is internal to Laravel before Middleware calls.
Additional Context
This suddenly started happening today in our server. It happens when users connect to the server through the web app from select systems. Even though system kind should not affect server side response generation but still web app always generates this error for specific PCs/Mobiles.
Proposed Hack
After sifting through the Symfony bug report, the easiest workaround I have found is to just clear the error through an inconsequential json_encode('1') call. Which effectively resets the error code to 0 and the later JSON methods work fine.
Fortunately we have our own response generation class so just adding this before the hand-off to Laravel works fine.
Still this is a hack. I am more interested in a better solution or any bug fix available.

Issues with MantisBT and PhpStorm

I happily used PhpStorm and MantisBT together for months, but now I'm facing a strange problem.
Trying to establish a connection to my mantis instance (self hosted), I get the error:
Request failed. Reason: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
While I understand, what this error message means, I can't tell why it happens and I can't control the response I get from Mantis.
I neither found answers at the PhpStorm docs nor at Google nor at the Mantis bug tracker itself.
So I want to try my luck here. Is anyone else experiencing this or could give some advice?
Thanks to #user10550971 comment, I found the issue. The link to check if SOAP is enabled or not mentioned, that the PHP Soap extension was missing.
Although I would have sworn, that I didn't make any changes at server side, I did.
I updated my PHP version and forgot to install SOAP.

Elasticsearch does not return jsonp

im trying to connect my polymer element to my own elasticsearch-server.
My first problem was, that they are on two different ports, so it had to choose JSONP because of Cross-Domain problems.
So I found out, that I just have to add
http.jsonp.enable: true
in the elasticsearch.yml.
Im starting the server simply by executing the "elasticsearch.bat".
I've indexed data.
If I try to load the API via iron-jsonp-library, im always getting an unexpected token error.
<iron-jsonp-library id="libraryLoader"
library-url="http://127.0.0.1:9200/data/_search?pretty%%callback%%"
notify-event="api-load"
callbackName="jsonpCallback">
</iron-jsonp-library>
In Google Chrome, I'm getting following result from elasticsearch
{"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":5,"max_score":1.0,"hits":[{"_index":"data","_type":"data","_id":"5","_score":1.0,"_source":{"id":5,"name":"Meyr","manufacturer":"Meyr","weight":1.0,"price":1.0000,"popularity":1,"instock":true,"includes":"Meyr"}},{"_index":"data","_type":"data","_id":"2","_score":1.0,"_source":{"id":2,"name":"Meier","manufacturer":"Meier","weight":1.0,"price":1.0000,"popularity":1,"instock":true,"includes":"Meier"}},{"_index":"data","_type":"data","_id":"4","_score":1.0,"_source":{"id":4,"name":"Mair","manufacturer":"Mair","weight":1.0,"price":1.0000,"popularity":1,"instock":true,"includes":"Mair"}},{"_index":"data","_type":"data","_id":"1","_score":1.0,"_source":{"id":1,"name":"Maier","manufacturer":"Maier","weight":1.0,"price":1.0000,"popularity":1,"instock":true,"includes":"Maier"}},{"_index":"data","_type":"data","_id":"3","_score":1.0,"_source":{"id":3,"name":"Mayr","manufacturer":"Mayr","weight":1.0,"price":1.0000,"popularity":1,"instock":true,"includes":"Mayr"}}]}}
Due to some internet knowledge of JSONP, its not jsonp.
Why is my elasticsearch server, not formatting right?
Are you prior to v2.0? Looks like they removed jsonp in 2.0 (elastic.co/guide/en/elasticsearch/reference/2.2/…).
Alsopretty%%callback%% doesn't look right, the %%callback%% macro usually needs to be the value of name (like onload=%%callback%%). The element replaces %%callback%% with the name of a global function that is generated for you.

https from as3 air project to webservice using as3httpclientlib

I am trying to change webservice implementation I have done over to use HTTPS.
I have been using the as3httpclientlib (https://code.google.com/p/as3httpclientlib/).
When I use a non-ssl endpoint it works as expected.
However when I use an SSL endpoint and version 1.3 as3crypt from the downloads page (https://code.google.com/p/as3crypto/downloads/list) or the included as3crypto-1_3_patched.swc I get the following:
I DONT KNOW HOW TO HANDLE DER stuff of TYPE 22
I DONT KNOW HOW TO HANDLE DER stuff of TYPE 22
I DONT KNOW HOW TO HANDLE DER stuff of TYPE 22
I DONT KNOW HOW TO HANDLE DER stuff of TYPE 22
I DONT KNOW HOW TO HANDLE DER stuff of TYPE 12
I DONT KNOW HOW TO HANDLE DER stuff of TYPE 22
I DONT KNOW HOW TO HANDLE DER stuff of TYPE 22
I DONT KNOW HOW TO HANDLE DER stuff of TYPE 22
I DONT KNOW HOW TO HANDLE DER stuff of TYPE 22
[Fault] exception, information=TypeError: Error #1009: Cannot access a property or method of a null object reference.
With the traces originating from Line 123 of DER.as
https://code.google.com/p/as3crypto/source/browse/trunk/as3crypto/src/com/hurlant/util/der/DER.as?r=7
and the error from line 225 of X509Certificate.as
https://code.google.com/p/as3crypto/source/browse/trunk/as3crypto/src/com/hurlant/crypto/cert/X509Certificate.as?spec=svn28&r=7
When I use the latest version of as3crypt https://code.google.com/p/as3crypto/source/detail?r=28 I get
[Fault] exception, information=Error: couldn't parse DER stream.
Thrown from line 23 of https://code.google.com/p/as3crypto/source/browse/trunk/as3crypto/src/com/hurlant/util/asn1/type/SetType.as
The webservice I am trying to access is on azurewebsites, so will be using the *.azurewebsites.net certificate.
I am also using the ASC2 compiler, this caused a couple of bugs which I had to fix in the crypto project including changing if (hex.length&1==1) hex="0"+hex; to if ((hex.length&1)==1) hex="0"+hex; which I found posted here com.hurlant.util.hex syntax error on air sdk 3.5
I am starting to think it may be something related to the way SSL is done on Azure websites, since when I strip back the request completely, I still get the same error, however pointing to https://www.google.com, I get no error.
They state on their website:
HTTPS doesn't always work. There are some minor bugs with the
as3crypto library, so for example https at yahoo and yahoo owned
domains (like delicious) don't currently work.
I had a look through the list of issues for as3crypt, and was wondering whether one of these contained a fix: https://code.google.com/p/as3crypto/issues/list
Does anyone know why I am getting these errors (what it is that azure are doing differently with their certificate (could it be the wildcard?)) and how I can fix it? Is there a maintained version of as3crypto that works? Or is there a better way for consuming https webservices from Air mobile apps?
****UPDATE****
I tried using the patched version of as3crypto but still no joy. The following is a copy of my stack trace when it errors. Does seem to be an error parsing the certificate?
I also had a look into changing over to SecureSocket but unfortunately it is not supported on iOS.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/SecureSocket.html
AIR profile support: This feature is supported on all desktop
operating systems, but is not supported on all AIR for TV devices. On
mobile devices, it is supported on Android, but not on iOS. You can
test for support at run time using the SecureSocket.isSupported
property.
TO RECREATE:
Make a get request to any https subdomain of azurewebsites.net.
ie the following code will reproduce:
var client:HttpClient = new HttpClient();
client.get(new URI("https://httpstest.azurewebsites.net"));
I have the same issue with DER decoing, and fix from this issue helped me:
http://code.google.com/p/as3crypto/issues/detail?id=39
What about:
Or is there a better way for consuming https webservices from Air mobile apps?
You can try to substitute TLSSocket from as3crypto with Flash native SecureSocket in the as3httpclient, I think it shouldn't be too difficult to do. In my project I tryed to use both SecureSoket and TLSSocket and stood on TLSSocket because SecureSoket requires FP 11 and doesn't work with self-signed certificates that we use on test server, but SecureSoket also works fine and has shown even better performance that TLSSocket. You also can grab already patched version of as3crypto from my github (https://github.com/fsbmain/as3public) :)
If you still have problems, please provide endpoint of your webservice so I'll be able test it.
UPD:
I were able to reproduce your issue and tested certificate parsing with my patched as3crypto lib (it still allows to go deeper through the parsing), I also tested parsing of the same certificate but downloaded with the browser - the same result in both cases (as on your screenshot), so the conclusion is that TLSSocket loads correct and full bytes of certificate but fails to parse it. I tried to fix the parsing but it requires deeper dive into the as3crypto DER format implementation. So I'm afraid the only way to use as3httpclient is to fix DER parsing.
BTW why doesn't standard URLLoader fit you?
The as3crypto.swc file here: http://www.igniterealtime.org/downloads/download-landing.jsp?file=xiff/xiff_3_1_0.zip solved my issue.
as3crypto.swc is inside the libs folder, after extracting.