libCurl gives unsupported protocol on a script running as cron job - c++

Here is my situation: I have an sh script that writes some data to text files then calls a pre-built c++ binary that processes these text files and uses libCurl to send an email. Under the user that created the script and the binary everything is working fine, the email is delivered perfectly. Something goes wrong when executing the script under the cron daemon. Permissions-wise, the script and binary have 777 and the text files have 666. I have created another user and tried executing the binary it gave me the following error:
* Protocol smtp not supported or disabled in libcurl
* Unsupported protocol
curl_easy_perform() failed: Unsupported protocol
After the cron period passed the shell gave a message something like You have a new mail in/var/spool/mail/$USER, that file contains the same message.
Executing curl -V on both users:
curl 7.48.0 (i686-pc-linux-gnu) libcurl/7.48.0 OpenSSL/1.0.0 zlib/1.2.3 libidn/1.18
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: IDN IPv6 Largefile NTLM NTLM_WB SSL libz UnixSockets
Any help is really appreciated.

Related

Libcurl no support for https but curl does

When I run curl -V my output is this
curl 7.82.0-DEV (x86_64-pc-win32) libcurl/7.82.0-DEV OpenSSL/1.1.1m WinIDN
Release-Date: [unreleased]
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS HSTS HTTPS-proxy IDN IPv6 Kerberos Largefile NTLM SPNEGO SSL SSPI UnixSockets alt-svc
Https is clearly there. When I use it through c++, by using curl_version_info_data
curl_version_info_data* ver = curl_version_info(CURLVERSION_NOW);
for (int i = 0; i < 14; ++i) {
cout << ver->protocols[i] << endl;
}
The supported protocols listed are
dict
file
ftp
gopher
http
imap
ldap
mqtt
pop3
rtsp
smb
smtp
telnet
tftp
If I try using https, I get the error Unsupported protocol. Anyone get any ideas?
I figured it out, when running I tried fixing by grabbing libcurl.lib and libcurl_imp.lib from a precompiled version of Curl (I had two versions installed). The precompiled version did not have support for https. I read the FAQ here https://curl.se/docs/faq.html and properly linked the static library. Afterwards, it worked fine.

libcurl HTTPS enabled but not usable

For our project we build libcurl from scratch over cmake. The libcurl-configure-out.log tells me it enabled HTTPS (among others), heres the important part about that:
-- Enabled features: SSL IPv6 unixsockets AsynchDNS Largefile alt-svc HSTS NTLM HTTPS-proxy
-- Enabled protocols: DICT FILE FTP FTPS GOPHER GOPHERS HTTP HTTPS IMAP IMAPS LDAP MQTT POP3 POP3S RTSP SCP SFTP SMB SMBS SMTP SMTPS TELNET TFTP
-- Enabled SSL backends: OpenSSL
But when I try to set a TLS version in our code, it says "CURLE_NOT_BUILT_IN"
const CURLcode state = curl_easy_setopt(this->m_curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
// state == 4 aka "CURLE_NOT_BUILT_IN"
I also tried to verify over the curl executable, which kinda gives me the same impression
C:<snip>\build\ex_libcurl-prefix\src\ex_libcurl-build\src\Debug>curl.exe --version
curl 7.80.0 (Windows) libcurl/7.80.0 libssh2/1.10.0
Release-Date: 2021-12-10
Protocols: dict file ftp gopher http imap ldap mqtt pop3 rtsp scp sftp smb smtp telnet tftp
Features: AsynchDNS HSTS IPv6 Largefile NTLM UnixSockets alt-svc
Where did I go wrong?
Edit: Some more parts about SSL beeing enabled:
-- Found OpenSSL: optimized;C:/Program Files/OpenSSL-Win64/lib/VC/libcrypto64MD.lib;debug;C:/Program Files/OpenSSL-Win64/lib/VC/libcrypto64MDd.lib (found version "3.0.0")
-- Looking for openssl/crypto.h
-- Looking for openssl/crypto.h - found
-- Looking for cldap_open in wldap32;winmm;ws2_32;OpenSSL::SSL;OpenSSL::Crypto
-- Looking for cldap_open in wldap32;winmm;ws2_32;OpenSSL::SSL;OpenSSL::Crypto - found

CURLE_UNSUPPORTED_PROTOCOL - ftp download fails

i use cURL (installed via vcpkg). Also openssl installed via vcpkg for a c++ project on VS 2019.
The problem:
CURLE_UNSUPPORTED_PROTOCOL = curl_easy_perform(curl);
I used this example:
https://curl.haxx.se/libcurl/c/ftpsget.html
with corrected connection and file data. The FTP server is filezilla. I checked the connection and file
download with filezilla client. All fine.
When i use the sample from link, i get the CURLE_UNSUPPORTED_PROTOCOL and in my FTP server i can't see
any connection try.
The error is described like this:
The URL you passed to libcurl used a protocol that this libcurl does not support..
Verbose information is:
* STATE: INIT => CONNECT handle 0x148090e0b38; line 1356 (connection #-5000)
* Protocol "ftp" not supported or disabled in libcurl
* Closing connection -1
* Expire cleared (transfer 0x148090e0b38)
I check the internet for the error message above and none of those i found solved my problem.
It seems not to be a format problem or problem related to wrong url .
So my question is, where can i enable this ? Do i need additional packages ? Or is the problem elsewhere ?
Many thanks
Mean while i figured out how to accomplish this using latest curl command line tool (version 7.68.0) on windows:
curl -u my_user:my_password --ftp-ssl ftp://my_ip/my_relative_path/my_file --insecure -o my_file
The file for download is on a server where a FileZilla FTP server is working. This server cyphers with a self created cert. The curl client only accepts this, when using flag:
--insecure
So far, i could not find the related options for my c++ curl. Perhaps it is not possible at all, because sources available through vcpkg are not (yet) up to date. But i want to stick with vcpkg. For me, this solutions: using command line tool instead, works fine.
One more hint, which is important: curl version 7.64.00 works NOT. You get error:
curl: (35) schannel: failed to receive handshake, SSL/TLS connection failed

Protocol https not supported or disabled in libcurl in Redhat Linux 8

I have an C++ application which is using curl 7.61.1 version.
while trying to connect to device using ssl I get this error:
"Protocol https not supported or disabled in libcurl"
although the default curl version installed in RHEL8 supports https
curl --version
curl 7.61.1 (x86_64-redhat-linux-gnu) libcurl/7.61.1 OpenSSL/1.1.1 zlib/1.2.11 brotli/1.0.6 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) libssh/0.8.3/openssl/zlib nghttp2/1.33.0
Release-Date: 2018-09-05
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz brotli TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL Metalink
please suggest how to configure/use curl with ssl in Redhat Linux 8

Is there any way to use POP3 for recving mail over localhost wamp?

I am trying to check receive mail script on local server but can't connect to localhost on wamp. Is there any POP3 extension for wamp ?