Skip to content

Commit

Permalink
Improve the http tutorial.
Browse files Browse the repository at this point in the history
  • Loading branch information
floitsch committed Mar 6, 2024
1 parent 3e5e713 commit c1c66c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
12 changes: 8 additions & 4 deletions docs/tutorials/network/http.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ PATH ::= "/random.json?language=en"
main:
certificate-roots.install-common-trusted-roots
network := net.open
client := http.Client.tls network
Expand All @@ -70,7 +71,11 @@ However, things are complicated by two facts:

In order to verify the authenticity of the https server we need
to have the certificate of the authenticity that signed the server's
own certificate. In the case of https://uselessfacts.jsph.pl the root
own certificate. For simplicity we just install the "common trusted roots"
of the `certificate-roots` package. This is a set of root certificates
that cover the majority of the internet.

In the case of https://uselessfacts.jsph.pl the root
authority is "ISRG Root X1". This information can be extracted by
looking at the site's certificate in Chrome:

Expand All @@ -79,9 +84,8 @@ looking at the site's certificate in Chrome:
alt="Certificate information in Chrome"
/>

The `certificate-roots` package is maintained by Toitware and contains
some of the most common roots. The included roots are the ones that are
shipped with Mozilla's Firefox and should thus be safe to use.
The `certificate-roots` package is maintained by Toitware and includes roots
that are shipped with Mozilla's Firefox and should thus be safe to use.

Decoding the given data as JSON is straightforward with the `decode-stream`
functionality of the `json` library (imported with `encoding.json`).
Expand Down
1 change: 1 addition & 0 deletions tutorial_code/http/http.toit
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ PATH ::= "/random.json?language=en"

main:
certificate-roots.install-common-trusted-roots

network := net.open
client := http.Client.tls network

Expand Down

0 comments on commit c1c66c4

Please sign in to comment.