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

add AMQPS support #32

Merged
merged 1 commit into from Jan 19, 2021
Merged

add AMQPS support #32

merged 1 commit into from Jan 19, 2021

Conversation

tanmaykm
Copy link
Member

@tanmaykm tanmaykm commented Jan 19, 2021

This adds AMQPS (TLS) connections support.

The IANA assigned port number for AMQPS is 5671. It is available as the constant AMQPClient.AMQPS_DEFAULT_PORT.

An example of making an AMQPS connection:

conn = connection(; virtualhost="/",
    host = "amqps.example.com",
    port = AMQPClient.AMQPS_DEFAULT_PORT,
    auth_params = Dict{String,Any}("MECHANISM"=>"AMQPLAIN", "LOGIN"=>"guest", "PASSWORD"=>"guest"),
    amqps = amqps_configure()
)

The amqps_configure method can be provided additional parameters for TLS connections:

  • cacerts: A CA certificate file (or it's contents) to use for certificate verification.
  • verify: Whether to verify server certificate. Default is false if cacerts is not provided and true if it is.
  • client_cert and client_key: The client certificate and corresponding private key to use. Default is nothing (no client certificate). Values can either be the file name or certificate/key contents.
amqps_configure(;
    cacerts = nothing,
    verify = MbedTLS.MBEDTLS_SSL_VERIFY_NONE,
    client_cert = nothing,
    client_key = nothing
)

fixes: #19

This adds AMQPS (TLS) connections support.

The IANA assigned port number for AMQPS is 5671. It is available as the constant `AMQPClient.AMQPS_DEFAULT_PORT`.

An example of making an AMQPS connection:

```julia
conn = connection(; virtualhost="/",
    host = "amqps.example.com",
    port = AMQPFlient.AMQPS_DEFAULT_PORT
    auth_params = Dict{String,Any}("MECHANISM"=>"AMQPLAIN", "LOGIN"=>"guest", "PASSWORD"=>"guest"),
    amqps = amqps_configure()
)
```

The `amqps_configure` method can be provided additional parameters for TLS connections:
- cacerts: A CA certificate file (or it's contents) to use for certificate verification.
- verify: Whether to verify server certificate. Default is false if cacerts is not provided and true if it is.
- client_cert and client_key: The client certificate and corresponding private key to use. Default is nothing (no client certificate). Values can either be the file name or certificate/key contents.

```julia
amqps_configure(;
    cacerts = nothing,
    verify = MbedTLS.MBEDTLS_SSL_VERIFY_NONE,
    client_cert = nothing,
    client_key = nothing
)
```
@tanmaykm
Copy link
Member Author

Coverage decreased because CI does not cover AMQPS mode yet.

@tanmaykm tanmaykm merged commit 737741e into master Jan 19, 2021
@delete-merged-branch delete-merged-branch bot deleted the tan/amqps branch January 19, 2021 12:28
@phinzphinz
Copy link

phinzphinz commented Feb 14, 2021

I think you should have a default parameter =nothing here:

amqps::Union{MbedTLS.SSLConfig,Nothing})

Otherwise you will get this error when not explicitly specifying the amqps keyword parameter:
ERROR: LoadError: UndefKeywordError: keyword argument amqps not assigned

tanmaykm added a commit that referenced this pull request Feb 15, 2021
This fixes issue where the keyword parameter `amqps` was missing a value in `connection` method.

Ref: #32 (comment)
@tanmaykm
Copy link
Member Author

Yes indeed. Thanks for reporting!
This should fix it: #39

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

Successfully merging this pull request may close these issues.

How can I connect to amqps?
2 participants