components-contrib icon indicating copy to clipboard operation
components-contrib copied to clipboard

Does dapr support the AMPQs (Secure AMPQ) protocol when using rabbitmq for pubsub?

Open bab5470 opened this issue 3 years ago • 5 comments

Does dapr support the AMPQs (Secure AMPQ) protocol when using rabbitmq for pubsub?

When we specify the following in our dapr pubsub config our setup works:

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: pubsub
  namespace: backend
spec:
  type: pubsub.rabbitmq
  version: v1
  metadata:
  - name: host
    value: "amqp://username:[email protected]:5672"
  - name: exchangeKind
    value: topic
  - name: durable
    value: true
  - name: deleteWhenUnused
    value: false

When we switch the config as follows it breaks:

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: pubsub
  namespace: backend
spec:
  type: pubsub.rabbitmq
  version: v1
  metadata:
  - name: host
    value: "amqps://username:[email protected]:5671"
  - name: exchangeKind
    value: topic
  - name: durable
    value: true
  - name: deleteWhenUnused
    value: false

Note all we've changed is the protocol from ampq to ampqs and the port from 5672 to 5671.

We are using our own internal CA when securing rabbitmq so I don't know if there is some way to get the daprd sidecar to trust our internal CA's cert when connecting to rabbitmq?

Thanks, Brad

bab5470 avatar Aug 15 '22 16:08 bab5470

Moved to correct repository. Thanks for reporting this @bab5470, it's currently not supported it seems.

yaron2 avatar Aug 23 '22 22:08 yaron2

/assign

SpikeWong avatar Aug 30 '22 11:08 SpikeWong

According to my findings, currently secure amqp is supported. Based on official rabbitmq documentation, you can set the parameters for tls in the uri, eg. amqps://localhost:5671?cacertfile=/path/to/ca_cert.pem&keyfile=/path/to/key.pem&certfile=/path/to/cert.pem. We are currently using the dial method of amqp library(ref: https://github.com/dapr/components-contrib/blob/bcea284c7b0c1a5a07294021a2bb6cc74909da35/bindings/rabbitmq/rabbitmq.go#L79), which supports the establishment of TLS connections. I've done tests in my local development env and found nothing wrong.

SpikeWong avatar Aug 31 '22 05:08 SpikeWong

@yaron2 @bab5470 Could you confirm it, not sure I fully understand the intent of this issue.

SpikeWong avatar Sep 02 '22 02:09 SpikeWong

@yaron2 Hi, do you have time to confirm this? https://github.com/dapr/components-contrib/issues/2008#issuecomment-1232489072

SpikeWong avatar Sep 08 '22 10:09 SpikeWong

Maybe #2129 relates to this

berndverst avatar Sep 24 '22 05:09 berndverst

How would I load the ca.pem file (or the certs) in the sidecar so this works?

On Thu, Sep 1, 2022 at 10:40 PM spike @.***> wrote:

@yaron2 https://github.com/yaron2 @bab5470 https://github.com/bab5470 Could you confirm it, not sure I fully understand the intent of this issue.

— Reply to this email directly, view it on GitHub https://github.com/dapr/components-contrib/issues/2008#issuecomment-1235004484, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6OR6CBPOT54OYTEUEHA5TV4FSKFANCNFSM57NGV6MQ . You are receiving this because you were mentioned.Message ID: @.***>

bab5470 avatar Oct 11 '22 08:10 bab5470

In Kubernetes you need to mount those certs as storage (PVC) or as secret into the file system of the sidecar itself. The connection string referring to the certs as suggested above would then specify the path to the certs mounted into the sidecar container.

In standalone mode you can use the local file system absolute path.

I haven't verified this for RabbitMQ specifically but it should work.

berndverst avatar Oct 11 '22 08:10 berndverst

https://github.com/dapr/components-contrib/issues/2246 this seems related

berndverst avatar Nov 02 '22 16:11 berndverst

comment by anoymouscoder and comment by berndverst can support AMPQs for sure. But this way request users know rabbitmq and kubernetes well. @anoymouscoder I think you should add cacertfile、certfile、keyfile to metadata, who's value are there pem content. Just as what kafka pubsub dose. And then form them into a tlsConfig, use amqp.DialTLS("amqps://localhost:5671/", tlsConf) to connect to the server. this pr may help you know how to add these to metadata.

Taction avatar Nov 04 '22 08:11 Taction

@Taction Got it, I will start working on this.

SpikeWong avatar Nov 06 '22 01:11 SpikeWong

Docs issue: https://github.com/dapr/docs/issues/2953 - @SpikeWong is working on it

berndverst avatar Feb 01 '23 21:02 berndverst