Skip to content

How to use TLS? #55

Description

@DazWilkin

The README.md is lacking in documenting how to use TLS Support:

"If you need TLS support for the server, you'll need to compile with the ssl feature set."

I'm willing to augment the README.md with the solution but I'm unable to get it working myself 😞

I'm unable to curl the TLS endpoint (403):

curl \
--insecure \
--key privatekey.pem \
--cert certificate.pem \
--write-out '%{response_code}' \
https://${HOST}:8888

And I'm unable to discover the device in the gateway.

thing-url-adapter:
Failed to connect to https://${HOST}.local:8888:
FetchError: request to https://${HOST}.local:8888/ failed, reason: self signed certificate

I believe, in the example code, I should replace:

webthing = "0.13.2"

with, e.g.:

[dependencies.webthing]
path = "../webthing-rust"
version = "0.13.2"
features = ["ssl"]

Then:

  • I generated a self-signed cert using HOST=localhost
  • I generated a self-signed cert using HOST=$(hostname).local
  • I referenced the privatekey.pem and certificate.pem from the WebThings Gateway's config's SSL directory
openssl req \
-x509 \
-nodes \
-days 365 \
-newkey rsa:2048 \
-keyout privatekey.pem \
-out certificate.pem \
-subj /CN=${HOST}

And:

let mut server = WebThingServer::new(
    ThingsType::Multiple(things, "Rusty-Device".to_owned()),
    Some(8888),
    None,
    Some(("privatekey.pem".to_string(), "certificate.pem".to_string())),
    Box::new(Generator),
    None,
)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions