Qt & SSL, Handshake failed - c++

I have a problem. I've made a Qt application which is connecting to a https site.
On my working machine, everything works fine. When I try to test my application on a clean Windows 7 machine, I observed the following issue:
After I have installed a fresh Win7 machine (installed all updates), after starting my application, I get a SSL Handshake failed error, SIGNAL(sslErrors(QNetworkReply*,QList)) is emitted with two empty error strings and error = QSslError::NoError.
I was really searching the whole day why this happens, also could reproduce it with examples\network\securesocketclient\release\securesocketclient and domain "google.com".
Now, I found out, that once I have started the internet explorer accessing https://www.google.com, my application is also working as expected and no further handshake errors are coming.
BTW, it does not matter which site you are accessing - this is not related to google.com.
Can someone explain to me why this happens? Is it a bug in OpenSSL, or Qt, or both?
UPDATE
I found a way to live with that issue for myself, implementing the following ignore logic:
QSslError ignoreNOErrors(QSslError::NoError);
foreach(QSslError error, errors)
if(error.error() != QSslError::NoError)
qDebug() << error.errorString();
QList<QSslError> expectedSslErrors;
expectedSslErrors.append(ignoreNOErrors);
reply->ignoreSslErrors(expectedSslErrors);
Thanks

You could ignore certificate verify using QSslConfiguration::setPeerVerifyMode():
QSslConfiguration conf = request.sslConfiguration();
conf.setPeerVerifyMode(QSslSocket::VerifyNone);
request.setSslConfiguration(conf);

I was facing the same issue on Mac with Qt 5.5 and 5.6. When I upgraded to 5.7 it is solved. Hope it may help if you are still facing this issue.

Have a look at this Qt bug
[This is padding for SO :D]

Related

Remote-SSH Vscode - problem - "tput: No value for $TERM and no -T specified"

Situation:
I'm unable to connect to remote machnie via vscode + remote-SSH.
I CAN though connect to that machine using SSH from any shell.
Before the problem when I shut down my machine there was mandatory Windows update...
First error I get in terminal just after "You are connected to: [company-servername]" is:
After this there is never-ending error log whit most errors are similar to:
What I have already tried:
reinstalling Remote-ssh
killing vscode remote-server
making additional space on remote
running without any extensions except remote-ssh
reinstalling vscode
deleting all vscode config files and reinstalling
deleting vscode config files on remote in my home
I'm a bit stuck here, and our foreign 'Support' isn't very supportive...
maybe anyone had similar problem or has any idea?
FYI I managed to fix the problem which was really trivial...
Some facts:
Problem was with REMOTE SERVER not VSCODE
As "tput: no value for $TERM" suggested something 'with terminal'
So what I did was clean my .bashrc to some generic sample. And it worked.
After investigation I figured that in my .bashrc I have
source /somepath/myAliases
which causes the problem. So what in that file was wrong?
In 'myAliases' there was broken alias where I used invalid quotation:
alias name='some commands' #OK
alias name="some commands" #OK
alias name=`some commands` # <-- this caused error shown above.
I hope this explanation may be of some use to any of you.
BR

Unexpected error using grpc arena allocation

I am writing a c++ grpc based service. As recommended here, I installed grpc in my local directpry. I am using linux ubuntu 22.04.
Now, at he begginig of a service call implementation, i have these lines of code:
google::protobuf::Arena arena;
ResponseStatus * response_status =
google::protobuf::Arena::CreateMessage<ResponseStatus>(&arena);
response->set_allocated_status(response_status);
When I invoke the service, from a ruby client, the last line causes an exception with the following error message
[libprotobuf FATAL /home/lrleon/grpc/third_party/protobuf/src/google/protobuf/generated_message_util.cc:764] CHECK failed: (submessage_arena) == (nullptr):
I'll be honest: I do not have an good idea about why this problem could be happening. My best hypothesis is that somewhere a different version of the required grpc/protobuf libraries is intervening. I do not believe it because I am almost sure I am not using any system library related to grpc, but eventually another app could have installed some library.
I spent a full day searching in forums without getting a some related post that could help me solve mine.
That said, I kindly ask if some expert in grpc could help me.
Thanls in advance

How to make QSslSocket support SSL using an OpenSSL installation?

I'm trying to run a simple client/server to implement a communication using QSslSocket. I work on Windows (unfortunately) and I use QtCreator for more convenience.
When I try, from the client side, to connect to the server using MyQSslSocket->connectToHostEncrypted(ip, port), I get the following message:
qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed
When I print the raised error, I get the following one:
QAbstractSocket::SocketError(20)
In the documentation we can find that this error code corresponds to QAbstractSocket::SslInternalError whose the description is:
"The SSL library being used reported an internal error. This is probably the result of a bad installation or misconfiguration of the library."
After some investigations I found that Qt does not provide OpenSSL by itself so I installed it (the binaries, for both 32 and 64 bits versions to be sure) from here https://slproweb.com/products/Win32OpenSSL.html.
During the installation, the dll was copied to C:\Windows\System32 (for the 64 bits). Then I checked that the PATH environment variable does well contain this folder.
At this point I tried again, but I still had the same problem, as if the OpenSSL installation was still not found.
When I print the output of the following calls (in the main function of my client):
qDebug() << QSslSocket::supportsSsl();
qDebug() << QSslSocket::sslLibraryVersionString();
I get the following outputs:
false""
My question is, how to make QSslSocket::supportsSsl() return true ?
If anyone could teach me what I missed, what I am doing wrong and tell me what I should do to be able to make this SSL connection run properly, I would be very grateful.
Fareanor.
PS: Sorry for the long question but I think it is important to clearly expose the problem and the context to help you to easily understand the problem and give me more relevant answers.
Ok,
Thanks to #AlienPenguin and #Macias advices, it was that my version of OpenSSL was too recent.
Finally I have installed the closest available version of the one used for the Qt build (which does make sense, I should have thought of it) which can be found by running the following call:
qDebug() << QSslSocket::sslLibraryBuildVersionString();
Problem solved.
Thanks again.

libcurl malformed url error after upgrade (CURLE_URL_MALFORMAT)

I have a C++ client that connects to servers using libcurl on FreeBSD. The system administrators recently update the FreeBSD image and install ports. The system went from cURL version 7.24.0_2 to cURL version 7.31.0. (File name went from libcurl.so.6 to lib curl.so.7 for what that's worth.)
I recompiled my program to link against the new library.
Now I am getting return value 3 (CURLE_URL_MALFORMAT) from my call to curl_easy_perform(3), and the error message string returned is " malformed".
However, nothing else has changed. The URL is unchanged, and has been verified as correct.
Stranger still, the command line "curl" program works fine; isn't it using the same library?!
I've spent a couple hours reading the release notes for libcurl but couldn't spot anything that suggested a reason as to why this should now fail.
Any suggestions?
Turns out the sysadmins built cURL wrong. A new install and it works.

Connect to MS SQL Server through ODBC

I have a Qt 4 application that is trying to connect to an MS SQL Server 2008 database using the Qt ODBC driver. The application runs fine when it is running in Windows; however, the target OS for the application is to have it run in GNU/Linux. When the application runs in GNU/Linux I get the following error:
QSqlError(0, "QODBC3: Unable to connect", " [unixODBC][Driver Manager]Data source name not found, and no default driver specified")
Is there something I need to configure on the SQL server or application side to get the connection to work?
I don't really know much about unixODBC, but have a look here:
unixodbc.org/doc/
For connecting to MSSQL, the following might be useful:
http://www.unixodbc.org/doc/FreeTDS.html
or .../FreeTDS2.html
Try to copy the odbc.ini file in ~/.odbc.ini . If not working again, try to copy the same file into /etc/odbc.ini. If this is not working, as these directories are different for different Unix systems, find all files: *odbc*\.ini and see if some of them are empty. If so, replace them with the correct .ini file.
I had the same problem and this solved it. But it's a really stupid solution, so I'm looking for a better one. Hope that helped (: