Skip to content

Commit

Permalink
Merge pull request #75 from JuliaWeb/cv/libcurl_jll
Browse files Browse the repository at this point in the history
Switch to using LibCURL_jll / MozillaCACerts_jll
  • Loading branch information
omus authored May 21, 2020
2 parents 03ebd8f + 5439cbe commit 979c346
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 62 deletions.
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ os:
- osx
- freebsd
julia:
- 1.0
- 1.1
- 1.3
- nightly
notifications:
email: false
Expand All @@ -15,7 +14,7 @@ notifications:
after_success:
- |
julia -e '
VERSION >= v"0.7.0-DEV.3656" && using Pkg
VERSION >= v"0.7.0-DEV.5183" || cd(Pkg.dir("LibCURL"))
Pkg.add("Coverage"); using Coverage
using Pkg
Pkg.add("Coverage")
using Coverage
Codecov.submit(process_folder())'
11 changes: 6 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
name = "LibCURL"
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
version = "0.5.2"
version = "0.6.0"

[deps]
BinaryProvider = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
LibCURL_jll = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
MozillaCACerts_jll = "14a3606d-f60d-562e-9121-12d972cd8159"

[compat]
BinaryProvider = "0.5"
julia = "0.7, 1.0"
LibCURL_jll = "7.68"
MozillaCACerts_jll = ">= 2020"
julia = "1.3"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LibCURL.jl
[![codecov.io](http://codecov.io/github/JuliaWeb/LibCURL.jl/coverage.svg?branch=master)](http://codecov.io/github/JuliaWeb/LibCURL.jl?branch=master)

---
This is a simple Julia wrapper around http://curl.haxx.se/libcurl/ generated using [Clang.jl](https://github.com/ihnorton/Clang.jl).
This is a simple Julia wrapper around http://curl.haxx.se/libcurl/ generated using [Clang.jl](https://github.com/ihnorton/Clang.jl). Please see the [libcurl API documentation](https://curl.haxx.se/libcurl/c/) for help on how to use this package.

### Example (fetch a URL)

Expand Down Expand Up @@ -52,3 +52,22 @@ println("httpcode : ", http_code)
curl_easy_cleanup(curl)

```

### Binaries

This package uses the [LibCURL_jll](https://github.com/JuliaBinaryWrappers/libCURL_jll.jl) binary package to install compiled libCURL binaries on all supported platforms. The following products are defined in the jll

* `libcurl`: A `LibraryProduct` referencing the shared library
* `curl`: An `ExecutableProduct` referencing the binary

This package also uses the [MozillaCACerts_jll](https://github.com/JuliaBinaryWrappers/MozillaCACerts_jll.jl) package to supply the Mozilla CA root certificate bundle. Note that the `cacert` symbol is re-exported from this package for ease of use.

* `cacert`: A `FileProduct` referencing the Mozilla CA certificate bundle

### SSL certificates

Making SSL/TLS connections usually needs access to a CA certificate to validate peers. The Mozilla CA bundle can be used via this package. To use this certificate bundle, set the following option:

```julia
curl_easy_setopt(curl, CURLOPT_CAINFO, LibCURL.cacert)
```
3 changes: 1 addition & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
environment:
matrix:
- julia_version: 1.0
- julia_version: 1.1
- julia_version: 1.3
- julia_version: nightly

platform:
Expand Down
30 changes: 0 additions & 30 deletions deps/build.jl

This file was deleted.

16 changes: 5 additions & 11 deletions src/LibCURL.jl
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@

module LibCURL

using LibCURL_jll
using MozillaCACerts_jll

const time_t = Int
const size_t = Csize_t
const curl_off_t = Int64
const fd_set = Union{}
const socklen_t = Int32

const cacert = MozillaCACerts_jll.cacert

# Load libcurl libraries from our deps.jl
const depsjl_path = joinpath(dirname(@__FILE__), "..", "deps", "deps.jl")
if !isfile(depsjl_path)
error("LibCURL not installed properly, run Pkg.build(\"LibCURL\"), restart Julia and try again")
end
include(depsjl_path)

function __init__()
check_deps() # Always check your dependencies from `deps.jl`
end
export Mime_ext

include("lC_exports_h.jl")
include("lC_common_h.jl")
Expand All @@ -39,6 +34,5 @@ curl_easy_getinfo(handle, opt, ptrval::AbstractString) = ccall((:curl_easy_getin
include("lC_defines_h.jl")

include("Mime_ext.jl")
export Mime_ext

end
10 changes: 2 additions & 8 deletions test/ssl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,11 @@ end
curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_ALL)
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2)
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1)
curl_easy_setopt(curl, CURLOPT_CAINFO, LibCURL.cacert)

@testset "SSL Success" begin
res = curl_easy_perform(curl)
# NOTE: This will fail on macOS due to the cross compilation not knowing where the
# macOS CACerts would be
# The same issue would exist with Windows and FreeBSD as well
if Sys.isbsd() || Sys.iswindows()
@test_broken res == CURLE_OK
else
@test res == CURLE_OK
end
@test res == CURLE_OK
end

end
Expand Down

2 comments on commit 979c346

@omus
Copy link
Collaborator Author

@omus omus commented on 979c346 May 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/15117

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.0 -m "<description of version>" 979c346c6aada753bfa565d0f5f815cd0ef5b3f6
git push origin v0.6.0

Please sign in to comment.