Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No example or function to create an SSLConfig where you need a cert as a client #237

Open
fchorney opened this issue Nov 8, 2021 · 0 comments

Comments

@fchorney
Copy link

fchorney commented Nov 8, 2021

I recently had to use HTTP.jl and MbedTLS.jl to set up a situation where I was a client trying to submit a post request to an endpoint. The issue was that I needed to have a certificate to do this. There is a function the code base which sets this up when you want to act as a server (https://github.com/JuliaLang/MbedTLS.jl/blob/master/src/MbedTLS.jl#L108-L120) but not a client.

It would be nice if there was a similar function for when you want to act as a client. I ended up using the following:

    # Create SSL RNG
    entropy = MbedTLS.Entropy()
    rng = MbedTLS.CtrDrbg()
    MbedTLS.seed!(rng, entropy)

    # Read in the certificate files
    cert = MbedTLS.crt_parse_file(ssl_cert_path)
    key = MbedTLS.parse_keyfile(ssl_key_path)

    # Create SSLConfig with our pulled in certificate
    conf = MbedTLS.SSLConfig()
    MbedTLS.config_defaults!(conf)
    MbedTLS.rng!(conf, rng)
    MbedTLS.own_cert!(conf, cert, key)
    MbedTLS.ca_chain!(conf)

    return conf

On that note, similar to #231 it would be nice if MbedTLS could accept a singular pfx file instead of having to break it up into cert and key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant