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

NOISSUE - Update magistrala messaging #188

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

nyagamunene
Copy link
Contributor

What does this do?

It updated Magistrala messaging docs. It provides examples of how to do it.

List any changes that modify/break current functionality

It adds the functionality of running Magistrala with TLS and MTLS.

Have you included tests for your changes?

Yes.

Did you document any new/modified functionality?

Yes

Notes

Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
@nyagamunene nyagamunene self-assigned this May 20, 2024
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
@nyagamunene nyagamunene marked this pull request as ready for review May 21, 2024 10:05
Signed-off-by: nyagamunene <[email protected]>
@@ -1,33 +1,88 @@
# Messaging

Once a channel is provisioned and thing is connected to it, it can start to publish messages on the channel. The following sections will provide an example of message publishing for each of the supported protocols.
Once a channel is provisioned and thing is connected to it, it can start to publish messages on the channel. The following sections will provide an example of message publishing for each of the supported protocols, with the examples being shown without TLS, with TLS, and with mTLS.
> While using MTLS the `thing.crt` and `thing.crt` can be genarated by running `make thing_cert` while in the `docker/ssl` folder

Choose a reason for hiding this comment

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

thing.key and thing crt.

@@ -1,33 +1,88 @@
# Messaging

Once a channel is provisioned and thing is connected to it, it can start to publish messages on the channel. The following sections will provide an example of message publishing for each of the supported protocols.
Once a channel is provisioned and thing is connected to it, it can start to publish messages on the channel. The following sections will provide an example of message publishing for each of the supported protocols, with the examples being shown without TLS, with TLS, and with mTLS.
> While using MTLS the `thing.crt` and `thing.crt` can be genarated by running `make thing_cert` while in the `docker/ssl` folder

Choose a reason for hiding this comment

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

Also as it is mtls would it be more appropriate to have magistrala-client.key and magistrala-client.crt


## HTTP

To publish message over channel, thing should send following request:
The following environmental variables are used to enable or disable HTTP with TLS and MTLS: `MG_HTTP_ADAPTER_CERT_FILE`,`MG_HTTP_ADAPTER_KEY_FILE`, `MG_HTTP_ADAPTER_SERVER_CA_FILE`, `MG_HTTP_ADAPTER_CLIENT_CA_FILE`. These can be located in the `docker/.env` file.

Choose a reason for hiding this comment

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

Suggested change
The following environmental variables are used to enable or disable HTTP with TLS and MTLS: `MG_HTTP_ADAPTER_CERT_FILE`,`MG_HTTP_ADAPTER_KEY_FILE`, `MG_HTTP_ADAPTER_SERVER_CA_FILE`, `MG_HTTP_ADAPTER_CLIENT_CA_FILE`. These can be located in the `docker/.env` file.
The following environment variables are used to enable or disable HTTP with TLS and MTLS: `MG_HTTP_ADAPTER_CERT_FILE`,`MG_HTTP_ADAPTER_KEY_FILE`, `MG_HTTP_ADAPTER_SERVER_CA_FILE`, `MG_HTTP_ADAPTER_CLIENT_CA_FILE`. These can be located in the `docker/.env` file.


### Without TLS

To use magistala HTTP without TLS, comment out all of the listed environment variables provided above. To publish message over channel, thing should send following request:

Choose a reason for hiding this comment

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

You can also mention or provide an example for subscribing.

Note that if you're going to use senml message format, you should always send messages as an array.

For more information about the HTTP messaging service API, please check out the [API documentation][http-api].

## MQTT

To send and receive messages over MQTT you could use [Mosquitto tools][mosquitto], or [Paho][paho] if you want to use MQTT over WebSocket.
The following environmental variables are used to enable or disable MQTT with TLS and MTLS: `MG_MQTT_ADAPTER_CERT_FILE`, `MG_MQTT_ADAPTER_KEY_FILE`, `MG_MQTT_ADAPTER_SERVER_CA_FILE`, `MG_MQTT_ADAPTER_CLIENT_CA_FILE`.

Choose a reason for hiding this comment

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

Suggested change
The following environmental variables are used to enable or disable MQTT with TLS and MTLS: `MG_MQTT_ADAPTER_CERT_FILE`, `MG_MQTT_ADAPTER_KEY_FILE`, `MG_MQTT_ADAPTER_SERVER_CA_FILE`, `MG_MQTT_ADAPTER_CLIENT_CA_FILE`.
The following environment variables are used to enable or disable MQTT with TLS and MTLS: `MG_MQTT_ADAPTER_CERT_FILE`, `MG_MQTT_ADAPTER_KEY_FILE`, `MG_MQTT_ADAPTER_SERVER_CA_FILE`, `MG_MQTT_ADAPTER_CLIENT_CA_FILE`.

docs/messaging.md Outdated Show resolved Hide resolved
docs/messaging.md Outdated Show resolved Hide resolved
docs/messaging.md Outdated Show resolved Hide resolved
docs/messaging.md Outdated Show resolved Hide resolved
docs/messaging.md Show resolved Hide resolved
Copy link
Member

@rodneyosodo rodneyosodo left a comment

Choose a reason for hiding this comment

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

Also update coap messaging

panic(token.Error())
}
}

Copy link
Member

Choose a reason for hiding this comment

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

Add expected output

}
return []byte{}, nil
}

Copy link
Member

Choose a reason for hiding this comment

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

same

To use magistala HTTP without TLS, comment out all of the listed environment variables provided above. To publish message over channel, thing should send following request:

```bash
curl -s -S -i -X POST -H "Content-Type: application/senml+json" -H "Authorization: Thing <thing_secret>" http://localhost/http/channels/<channel_id>/messages -d '[{"bn":"some-base-name:","bt":1.276020076001e+09, "bu":"A","bver":5, "n":"voltage","u":"V","v":120.1}, {"n":"current","t":-5,"v":1.2}, {"n":"current","t":-4,"v":1.3}]'
Copy link
Member

Choose a reason for hiding this comment

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

For all examples add expected outputs

docs/messaging.md Outdated Show resolved Hide resolved
docs/messaging.md Outdated Show resolved Hide resolved

### With TLS

Uncomment out the following environment variables: `MG_MQTT_ADAPTER_WS_CERT_FILE`,`MG_MQTT_ADAPTER_WS_KEY_FILE` and comment out the rest to enable TLS certificates.

Choose a reason for hiding this comment

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

Suggested change
Uncomment out the following environment variables: `MG_MQTT_ADAPTER_WS_CERT_FILE`,`MG_MQTT_ADAPTER_WS_KEY_FILE` and comment out the rest to enable TLS certificates.
Uncomment the following environment variables: `MG_MQTT_ADAPTER_WS_CERT_FILE`,`MG_MQTT_ADAPTER_WS_KEY_FILE` and comment out the rest to enable TLS certificates.

docs/messaging.md Outdated Show resolved Hide resolved
docs/messaging.md Outdated Show resolved Hide resolved
```bash
curl -s -S -i --cacert docker/ssl/certs/ca.crt --cert docker/ssl/certs/thing.crt --key docker/ssl/certs/thing.key -X POST -H "Content-Type: application/senml+json" -H "Authorization: Thing <thing_secret>" https://localhost/http/channels/<channel_id>/messages -d '[{"bn":"some-base-name:","bt":1.276020076001e+09, "bu":"A","bver":5, "n":"voltage","u":"V","v":120.1}, {"n":"current","t":-5,"v":1.2}, {"n":"current","t":-4,"v":1.3}]'
```

Note that if you're going to use senml message format, you should always send messages as an array.

For more information about the HTTP messaging service API, please check out the [API documentation][http-api].

## MQTT

To send and receive messages over MQTT you could use [Mosquitto tools][mosquitto], or [Paho][paho] if you want to use MQTT over WebSocket.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
To send and receive messages over MQTT you could use [Mosquitto tools][mosquitto], or [Paho][paho] if you want to use MQTT over WebSocket.
To send and receive messages over MQTT, you can use [Mosquitto tools][mosquitto]. If you prefer to use MQTT over WebSocket, you can use [Paho][paho].

@dborovcanin
Copy link
Contributor

@nyagamunene @JeffMboya What's the status of this PR?

@nyagamunene
Copy link
Contributor Author

@nyagamunene @JeffMboya What's the status of this PR?

It was placed on hold because it is dependant on this PR

@dborovcanin
Copy link
Contributor

@nyagamunene What's the status of this PR?

@nyagamunene
Copy link
Contributor Author

nyagamunene commented Dec 18, 2024

@nyagamunene What's the status of this PR?

This is not ready it related to mtls and tls messaging

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

Successfully merging this pull request may close these issues.

5 participants