Billy Zha
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Avoid passing `--plain-http` when `--insecure` specified in oras When using ORAS to access plain-HTTP registry service, users need to specify `--plain-http`. ORAS CLI should be able to do automatic https-to-http handling via specifying `--insecure` and remove `--plain-http` flag. The detailed proposal and discussion are tracked in https://github.com/oras-project/oras/issues/914 This doc demonstrates the new experience of using `--insecure` flag and how automatic https-to-http handling in ORAS CLI. However, there are some edge cases for ORAS when the registry has local DNS configured using the ORAS flag `--resolve`. This doc also outlines this edge case and provides some options for open discussion. We will need to determine an appropriate experience from the given options. This doc also outlines the behaviors of other popular registry clients when interacting with insecure registries. ## Automatic https-to-http handling in ORAS CLI If ORAS CLI is changed to provide an `--insecure` flag with automatic https-to-http fallback, the low level implementation should look like below: ```mermaid sequenceDiagram participant A as oras participant B as registry(HTTP) rect rgb(191, 223, 255) A->>B: TLS handshake B-->>A: RecordHeader "HTTP/" A->>B:HTTP end Note over A,B: HTTP over TCP connection... ``` Related PR: https://github.com/oras-project/oras/pull/920 ## Working with customized DNS resolution Let's say we are going to use oras to access a HTTP registry service, `my.test.registry` which is running locally(0.0.0.0) at port 5000 ### Option 1: setup a DNS file User can setup a HOSTS file to hard-code DNS in a system level: ```shell oras login my.test.registry:5000 --insecure ``` ```mermaid sequenceDiagram participant A as oras participant D as HOSTS File participant B as 0.0.0.0:5000(HTTP) A->>D: match IP for my.test.registry D->>A: 0.0.0.0 rect rgb(191, 223, 255) A->>B: TLS handshake B-->>A: error + recordHeader="HTTP/" A->>B:HTTP end Note over A,B: HTTP over TCP connection... ``` This works fine with the UX of https->http auto handling via `--insecure`. ### Option 2: use `--resolve` without port redirection Sometimes users don't want to setup such a system-wide DNS rule. To customize the DNS resolution within command execution, user can use`--resolve host:port:address`, representing below endpoint mapping: ```mermaid flowchart LR A["host:port"] -->B["address:port"] ``` Below is an example of using it to log in to the registry `my.test.registry:5000` ```shell oras login my.test.registry:5000\ --resolve my.test.registry:5000:0.0.0.0\ --insecure ``` ```mermaid sequenceDiagram participant A as oras participant B as 0.0.0.0:5000(HTTP) participant C as resolve rules A->>C: match endpoint for my.test.registry:5000 C-->>A: 0.0.0.0:5000 rect rgb(191, 223, 255) A->>B: TLS handshake B-->>A: RecordHeader "HTTP/" A->>B:HTTP end Note over A,B: HTTP over TCP connection... ``` ### Option 3: use `--resolve` with port redirection #### why we need port redirection Sometimes user cannot add port in the registry name, e.g. `my.registy.com` and `my.registry.com:5000` can be used to run two different registry services. Suppose below command is used to login to a locally running HTTP registry at port `5000` ```console oras login my.test.registry\ --resolve my.test.registry:5000:0.0.0.0\ --insecure ``` The DNS resolution will fail since `my.test.registry:443` is not covered by the customized DNS rule: ```mermaid sequenceDiagram participant A as oras participant C as resolve rules participant B as DNS participant E as my.test.registry:443 participant D as 0.0.0.0:5000(HTTP) A->>C: match endpoint for my.test.registry:443 C-->>A: not found A->>B: query IP for my.test.registry B-->>A: 20.14.194.49 A->>E: TLS handshake Note over A,E: ... ``` #### https-to-http automatic handling with port redirection Introduced by ORAS, flag `--resolve host:port:address:address_port` represents: ```mermaid flowchart LR A["host:port"] -->B["address:address_port"] ``` With port redirection, ORAS users can ```bash oras login my.test.registry \ --resolve my.test.registry:443:0.0.0.0:5000 \ --resolve my.test.registry:80:0.0.0.0:5000 \ --insecure ``` The UX is quite verbose since both `443` and `80` rules are required to be specified: ```mermaid sequenceDiagram participant A as oras participant C as resolve rules participant D as 0.0.0.0:5000(HTTP) A->>C: match endpoint for my.test.registry:443 C-->>A: 0.0.0.0:5000 rect rgb(191, 223, 255) A->>D:TLS handshake D-->>A: RecordHeader "HTTP/" A->>C: match endpoint for my.test.registry:80 C-->>A: 0.0.0.0:5000 A->>D: HTTP end Note over A,D: HTTP over TCP connection... ``` ## What If - users want to access a registry with expired https cert This use case doesn't include https->http handling, user can simply use `--insecure`, like: ```bash oras login my.test.registry --insecure ``` - users need to login insecurely to a HTTP registry with customized DNS and **pull image without port** This is really an edge case but indeed, using `--plain-http` is much more simpler than HTTP auto fallback with`--insecure` ```bash oras login my.test.registry \ --resolve my.test.registry:443:0.0.0.0:5000 \ --resolve my.test.registry:80:0.0.0.0:5000 \ --insecure # or oras login my.test.registry \ --resolve my.test.registry:5000:0.0.0.0 \ --plain-http ``` - users need to login insecurely to a HTTP registry without port in the registry host name & custom HTTPS DNS rule is not specified Will fail because `my.test.registry:443` is not covered. Traffic will lands on remote registry(if it exists) instead of `0.0.0.0:5000`: ```bash oras login my.test.registry \ --resolve my.test.registry:80:0.0.0.0:5000 \ --insecure ``` ```mermaid sequenceDiagram participant A as oras participant C as resolve rules participant B as DNS participant E as my.test.registry:443 participant D as 0.0.0.0:5000(HTTP) A->>C: match endpoint for my.test.registry:443 C-->>A: not found A->>B: query IP for my.test.registry B-->>A: 20.14.194.49 A->>E: TLS handshake Note over A,E: HTTP over TCP connection... ``` - users need to login insecurely to a HTTP registry without port in the registry host name, HTTPS token service is running remotely Will fail, not supported ## Compare the user experience in other registry clients After investigated other registry clients like Docker, Skopeo, ctr, they provide automatic HTTPS->HTTP handling: - docker: user can mark a registry as insecure [in the configuration file](https://docs.docker.com/registry/insecure/#deploy-a-plain-http-registry). With insecure registries enabled, Docker goes through the following steps: - try using HTTPS. - If HTTPS is available but the certificate is invalid, ignore the error about the certificate. - If HTTPS is not available, fall back to HTTP. - skopeo: docker-like UX via flag`--tls-verify`, implementation based on mocked [configuration](https://github.com/containers/image/blob/main/docker/docker_client.go#L817) - containerd/nerdctl: docker-like UX via flag `--insecure-registry` ([fallback code](https://github.com/containerd/nerdctl/blob/main/pkg/imgutil/imgutil.go#L148)) The ctr CLI requires user to specify whether a remote registry supports TLS explicitly(this is currently ORAS' UX): - containerd/ctr: has specific flags for using plain HTTP `--plain-http` and skipping TLS check `--skip-verify/-k`

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully