I have been working on setting up some automated tasks at work that use curl to connect to FTPS on a remote server. On one of the development servers I was testing from I attempted to issue a curl command using the “–libcurl” switch which returned an error. This command was recommended by a coworker as a start to set up the automated tasks to connect to FTPS on the remote server using curl. Below I describe the error in detail, the cause of the error, and how to resolve the error.
Curl Error Using Curl 7.15 On CentOS Linux:
- [root@dev ftptest]# curl --ftp-ssl --insecure --libcurl ftpssl.c
- curl: option --libcurl: is unknown
- curl: try 'curl --help' for more information
- [root@dev ftptest]#
Why Curl On CentOS Linux Provides An Error With The libcurl Switch:
The above command would not technically complete anyway but I wanted to see if it would provide an error based on missing variables in the command or because of the switches. The current version of curl available on CentOS 5 is curl version 7.15.5-2.1 but the current curl release is curl version 7.20.0-1. After reading the curl changelog it looks like the “–libcurl” switch was added to curl in release 7.16.1. So the end result is if you want to use the libcurl switch you need to upgrade curl to a newer version which is discussed in more detail below.
Upgrade Curl On CentOS Linux:
Typically when I want to upgrade CentOS RPM packages that are not available in the default repositories I search for another repository that includes a version of the package I am looking for. In the case of curl I was unable to find a repo that included a version of curl above 7.15.5-2.1 which I would later find out is probably because so many other packages depend on libcurl.so.3 which is included in the curl-7.15.5-2.1.rpm package and when you upgrade to newer versions of curl the libcurl version upgrades to libcurl.so.4.
So the options you have are either to find a way to install curl from source, build a rpm package from source, or you can try to use the curl package I built for curl version 7.20.0-1. What I ended up doing was including the libcurl.so.3 library files so when I upgraded to the new curl yum did not complain about the libcurl.so.3 dependency required by packages such as php-common.
**NOTE: I am by no means an expert building RPM packages so use the package I provide below at your own risk.
Download & Install Curl 7.20.0-1 For CentOS Linux:
- Download curl 7.20.0-1 CentOS RPM Package: Click here to download the curl-7.20.0-1.i386.rpm built on CentOS version 5.2. If you have gpgcheck set to 1 in yum.conf (which is the default setting) you should also download the Question Defense GPG Key titled QD-GPG-KEY and can be downloaded by clicking here. You can install the QD-GPG-KEY by issuing the below command.
Import The QD-GPG-KEY Using rpm:bash
- [root@dev ~]# rpm --import QD-GPG-KEY
If successfully imported there will be no output when importing the QD-GPG-KEY. After importing the key you will be able to successfully install the RPM package as explained in step 3 without having to modify the default yum configuration by changing the gpgcheck setting.
- Remove Old Curl Version: Use the rpm command with the –nodeps switch to remove your current version of curl installed on your CentOS Linux computer. If you attempted to remove this package with yum an error would display complaining of a dependency issue with libcurl.so.3.
Force Remove Curl Package From CentOS Linux:bash
- [root@dev i386]# rpm -e --nodeps curl-7.15.5-2.1.el5_3.5
The above command will not provide any output but if you run “rpm -qa | grep curl” after completing the above command you will see that curl is no longer installed.
- Install Curl 7.20.0-1 On CentOS: Now install the RPM package you have downloaded from step 1 by issuing the below command from the directory where the new curl package is located.
Install Curl 7.20.0-1, libcurl4, & libcurl3 On CentOS 5.X:bash
- [root@dev i386]# yum localinstall curl-7.20.0-1.i386.rpm
- Loading "fastestmirror" plugin
- Setting up Local Package Process
- Loading mirror speeds from cached hostfile
- * base: mirrors.cmich.edu
- * updates: mirrors.cmich.edu
- Examining curl-7.20.0-1.i386.rpm: curl - 7.20.0-1.i386
- Marking curl-7.20.0-1.i386.rpm as an update to curl - 7.15.5-2.1.el5_3.5.i386
- Resolving Dependencies
- --> Running transaction check
- ---> Package curl.i386 0:7.20.0-1 set to be updated
- --> Finished Dependency Resolution
- Dependencies Resolved
- Package Arch Version Repository Size
- curl i386 7.20.0-1 curl-7.20.0-1.i386.rpm 1.3 M
- Transaction Summary
- Install 0 Package(s)
- Update 1 Package(s)
- Remove 0 Package(s)
- Total download size: 1.3 M
- Is this ok [y/N]: y
- Downloading Packages:
- Running rpm_check_debug
- Running Transaction Test
- Finished Transaction Test
- Transaction Test Succeeded
- Running Transaction
- Updating : curl ######################### [1/2]
- Cleanup : curl ######################### [2/2]
- Updated: curl.i386 0:7.20.0-1
- Verify Curl Version: Now issue the below curl command to verify that curl is functioning properly after being upgraded to curl version 7.20.0-1.
Print Curl Version On CentOS Linux:bash
- [root@dev i386]# curl --version
- curl 7.20.0 (i686-pc-linux-gnu) libcurl/7.20.0 OpenSSL/0.9.8b zlib/1.2.3
- Protocols: dict file ftp ftps http https imap imaps ldap pop3 pop3s rtsp smtp smtps telnet tftp
- Features: IPv6 Largefile NTLM SSL libz
Your curl version is now upgraded and you have access to use the libcurl switch. Many other things have been added to curl between versions 7.15 and 7.20 including many bug fixes. I want to stress again that I am not an expert building RPM packages so I welcome any feedback relating to how I have accomplished the above and try to explain a bit more below.
How The Curl 7.20 CentOS RPM Package Was Built:
I first downloaded the source from the curl web site. I then used typically rpmbuild commands to build the package. After trying to install the RPM yum provided dependency errors regarding the libcurl.so.3 library. So I copied the current libcurl.so.3 symlink and the libcurl.so.3.0.0 library to the files that are built into the curl RPM package. I also had to add two lines to the spec file underneath the %files option to include both of the libcurl.so.3 files.