connectivity/networking/api/tls_credentials_shell.html · connectivity/networking/api/tls_credentials_shell.rst 공식 원문 ↗

Zephyr 3.7.0 · Connectivity · Networking API

TLS Credentials Shell

Credential을 buffer에 적재하고 추가·조회·삭제·나열하며 binary와 string 저장 형식을 명시적으로 제어합니다.

Official pathconnectivity/networking/api/tls_credentials_shell.html
Source fileconnectivity/networking/api/tls_credentials_shell.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

buf/add/del/get/list 명령, credential type keyword와 BIN·BINT·STR·STRT의 encoding·NULL 종료 차이를 설명합니다.

Commands

buf · add · del · get · list

Types

Cert · Key · PSK

Formats

BIN · BINT · STR · STRT

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 796DE81EF7CF2B3A58F339A3D1F6CBA7E60A27D9809F42C1F75BC29240A46A42
.. _tls_credentials_shell:

TLS Credentials Shell
#####################

The TLS Credentials shell provides a command-line interface for managing installed TLS credentials.

Commands
********

.. _tls_credentials_shell_buf_cred:

Buffer Credential (``buf``)
===========================

Buffer data incrementally into the credential buffer so that it can be added using the :ref:`tls_credentials_shell_add_cred` command.

Alternatively, clear the credential buffer.

Usage
-----

To append ``<DATA>`` to the credential buffer, use:

.. code-block:: shell

   cred buf <DATA>

Use this as many times as needed to load the full credential into the credential buffer, then use the :ref:`tls_credentials_shell_add_cred` command to store it.

To clear the credential buffer, use:

.. code-block:: shell

   cred buf clear

Arguments
---------

.. csv-table::
   :header: "Argument", "Description"
   :widths: 15 85

   "``<DATA>``", "Text data to be appended to credential buffer. It can be either text, or base64-encoded binary. See :ref:`tls_credentials_shell_add_cred` and :ref:`tls_credentials_shell_data_formats` for details."

.. _tls_credentials_shell_add_cred:

Add Credential (``add``)
=========================

Add a TLS credential to the TLS Credential store.

Credential contents can be provided in-line with the call to ``cred add``, or will otherwise be sourced from the credential buffer.

Usage
-----

To add a TLS credential using the data from the credential buffer, use:

.. code-block:: shell

   cred add <SECTAG> <TYPE> <BACKEND> <FORMAT>

To add a TLS credential using data provided with the same command, use:

.. code-block:: shell

   cred add <SECTAG> <TYPE> <BACKEND> <FORMAT> <DATA>


Arguments
---------

.. csv-table::
   :header: "Argument", "Description"
   :widths: 15 85

   "``<SECTAG>``", "The sectag to use for the new credential. Can be any non-negative integer."
   "``<TYPE>``", "The type of credential to add. See :ref:`tls_credentials_shell_cred_types` for valid values."
   "``<BACKEND>``", "Reserved. Must always be ``DEFAULT`` (case-insensitive)."
   "``<FORMAT>``", "Specifies the storage format of the provided credential. See :ref:`tls_credentials_shell_data_formats` for valid values."
   "``<DATA>``", "If provided, this argument will be used as the credential data, instead of any data in the credential buffer. Can be either text, or base64-encoded binary."

.. _tls_credentials_shell_del_cred:

Delete Credential (``del``)
===========================

Delete a specified credential from the credential store.

Usage
-----

To delete a credential matching a specified sectag and credential type (if it exists), use:

.. code-block:: shell

   cred del <SECTAG> <TYPE>

Arguments
---------

.. csv-table::
   :header: "Argument", "Description"
   :widths: 15 85

   "``<SECTAG>``", "The sectag of the credential to delete. Can be any non-negative integer."
   "``<TYPE>``", "The type of credential to delete. See :ref:`tls_credentials_shell_cred_types` for valid values."

.. _tls_credentials_shell_get_cred:

Get Credential Contents (``get``)
=================================

Retrieve and print the contents of a specified credential.

Usage
-----

To retrieve and print a credential matching a specified sectag and credential type (if it exists), use:

.. code-block:: shell

   cred get <SECTAG> <TYPE> <FORMAT>

Arguments
---------

.. csv-table::
   :header: "Argument", "Description"
   :widths: 15 85

   "``<SECTAG>``", "The sectag of the credential to get. Can be any non-negative integer."
   "``<TYPE>``", "The type of credential to get. See :ref:`tls_credentials_shell_cred_types` for valid values."
   "``<FORMAT>``", "Specifies the retrieval format for the provided credential. See :ref:`tls_credentials_shell_data_formats` for valid values."

.. _tls_credentials_shell_list_cred:

List Credentials (``list``)
===========================

List TLS credentials in the credential store.

Usage
-----

To list all available credentials, use:

.. code-block:: shell

   cred list

To list all credentials with a specified sectag, use:

.. code-block:: shell

   cred list <SECTAG>

To list all credentials with a specified credential type, use:

.. code-block:: shell

   cred list any <TYPE>

To list all credentials with a specified credential type and sectag, use:

.. code-block:: shell

   cred list <SECTAG> <TYPE>


Arguments
---------

.. csv-table::
   :header: "Argument", "Description"
   :widths: 15 85

   "``<SECTAG>``", "Optional. If provided, only list credentials with this sectag. Pass ``any`` or omit to allow any sectag. Otherwise, can be any non-negative integer."
   "``<TYPE>``", "Optional. If provided, only list credentials with this credential type. Pass ``any`` or omit to allow any credential type. Otherwise, see :ref:`tls_credentials_shell_cred_types` for valid values."


Output
------

The command outputs all matching credentials in the following (CSV-compliant) format:

.. code-block:: shell

   <SECTAG>,<TYPE>,<DIGEST>,<STATUS>

Where:

.. csv-table::
   :header: "Symbol", "Value"
   :widths: 15 85

   "``<SECTAG>``", "The sectag of the listed credential. A non-negative integer."
   "``<TYPE>``", "Credential type short-code (see :ref:`tls_credentials_shell_cred_types` for details) of the listed credential."
   "``<DIGEST>``", "A string digest representing the credential contents. The exact nature of this digest may vary depending on credentials storage backend, but currently for all backends this is a base64 encoded SHA256 hash of the raw credential contents (so different storage formats for essentially identical credentials will have different digests)."
   "``<STATUS>``", "Status code indicating success or failure with generating a digest of the listed credential. 0 if successful, negative error code specific to the storage backend otherwise. Lines for which status is not zero will be printed with error formatting."

After the list is printed, a final summary of the found credentials will be printed in the form:

.. code-block:: shell

   <N> credentials found.

Where `<N>` is the number of credentials found, and is zero if none are found.

.. _tls_credentials_shell_cred_types:

Credential Types
****************

The following keywords (case-insensitive) may be used to specify a credential type:

.. csv-table::
   :header: "Keyword(s)", "Meaning"
   :widths: 15 85

   "``CA_CERT``, ``CA``", "A trusted CA certificate."
   "``SERVER_CERT``, ``SELF_CERT``, ``CLIENT_CERT``, ``CLIENT``, ``SELF``, ``SERV``", "Self or server certificate."
   "``PRIVATE_KEY``, ``PK``", "A private key."
   "``PRE_SHARED_KEY``, ``PSK``", "A pre-shared key."
   "``PRE_SHARED_KEY_ID``, ``PSK_ID``", "ID for pre-shared key."

.. _tls_credentials_shell_data_formats:

Storage/Retrieval Formats
*************************

The :ref:`tls_credentials <sockets_tls_credentials_subsys>` module treats stored credentials as arbitrary binary buffers.

For convenience, the TLS credentials shell offers four formats for providing and later retrieving these buffers using the shell.

These formats and their (case-insensitive) keywords are as follows:

.. csv-table::
   :header: "Keyword", "Meaning", "Behavior during storage (``cred add``)", "Behavior during retrieval (``cred get``)"
   :widths: 3, 32, 34, 34

   "``BIN``", "Credential is handled by shell as base64 and stored without NULL termination.", "Data entered into shell will be decoded from base64 into raw binary before storage. No terminator will be appended.", "Stored data will be encoded into base64 before being printed."
   "``BINT``", "Credential is handled by shell as base64 and stored with NULL termination.", "Data entered into shell will be decoded from base64 into raw binary and a NULL terminator will be appended before storage.", "NULL terminator will be truncated from stored data before said data is encoded into base64 and then printed."
   "``STR``", "Credential is handled by shell as literal string and stored without NULL termination.", "Text data entered into shell will be passed into storage as-written, without a NULL terminator.", "Stored data will be printed as text. Non-printable characters will be printed as ``?``"
   "``STRT``", "Credential is handled by shell as literal string and stored with NULL-termination.", "Text data entered into shell will be passed into storage as-written, with a NULL terminator.", "NULL terminator will be truncated from stored data before said data is printed as text. Non-printable characters will be printed as ``?``"

The ``BIN`` format can be used to install credentials of any type, since base64 can be used to encode any concievable binary buffer.
The remaining three formats are provided for convenience in special use-cases.

For example:

- To install printable pre-shared-keys, use ``STR`` to enter the PSK without first encoding it.
  This ensures it is stored without a NULL terminator.
- To install DER-formatted X.509 certificates (or other raw-binary credentials, such as non-printable PSKs) base64-encode the binary and use the ``BIN`` format.
- To install PEM-formatted X.509 certificates or certificate chains, base64 encode the full PEM string (including new-lines and ``----BEGIN X ----`` / ``----END X----`` markers), and then use the ``BINT`` format to make sure the stored string is NULL-terminated.
  This is required because Zephyr does not support multi-line strings in the shell.
  Otherwise, the ``STRT`` format could be used for this purpose without base64 encoding.
  It is possible to use ``BIN`` instead if you manually encode a NULL terminator into the base64.

Part 3

한국어 전문 번역

TLS Credentials shell은 설치된 TLS credential을 관리하는 command-line interface를 제공합니다.

Commands

Buffer Credential (buf)

Credential data를 credential buffer에 점진적으로 추가한 뒤 add command로 저장할 수 있습니다. 반대로 credential buffer를 지울 수도 있습니다.

사용법

<DATA>를 credential buffer 뒤에 append하려면 다음을 사용합니다.

cred buf <DATA>

전체 credential을 buffer에 적재할 때까지 필요한 횟수만큼 반복한 다음 add command로 저장합니다.

Credential buffer를 비우려면 다음을 사용합니다.

cred buf clear

Arguments

Argument설명
<DATA>Credential buffer 뒤에 붙일 text data입니다. 일반 text 또는 base64-encoded binary일 수 있습니다. 자세한 내용은 add command와 storage/retrieval format 절을 참고하십시오.

Add Credential (add)

TLS Credential store에 TLS credential을 추가합니다.

cred add command와 함께 credential 내용을 inline으로 제공할 수 있으며, inline data가 없으면 credential buffer에서 가져옵니다.

사용법

Credential buffer의 data로 TLS credential을 추가하려면 다음을 사용합니다.

cred add <SECTAG> <TYPE> <BACKEND> <FORMAT>

같은 command에 data를 직접 제공해 TLS credential을 추가하려면 다음을 사용합니다.

cred add <SECTAG> <TYPE> <BACKEND> <FORMAT> <DATA>

Arguments

Argument설명
<SECTAG>새 credential에 사용할 security tag입니다. 0 이상의 integer를 사용할 수 있습니다.
<TYPE>추가할 credential type입니다. 유효한 값은 Credential Types 절을 참고하십시오.
<BACKEND>Reserved argument입니다. 대소문자와 관계없이 항상 DEFAULT여야 합니다.
<FORMAT>제공한 credential의 storage format을 지정합니다. 유효한 값은 Storage/Retrieval Formats 절을 참고하십시오.
<DATA>제공하면 credential buffer의 data 대신 이 argument를 credential data로 사용합니다. 일반 text 또는 base64-encoded binary일 수 있습니다.

Delete Credential (del)

Credential store에서 지정한 credential을 삭제합니다.

사용법

지정한 security tag와 credential type에 일치하는 credential이 있으면 다음 command로 삭제합니다.

cred del <SECTAG> <TYPE>

Arguments

Argument설명
<SECTAG>삭제할 credential의 security tag입니다. 0 이상의 integer를 사용할 수 있습니다.
<TYPE>삭제할 credential type입니다. 유효한 값은 Credential Types 절을 참고하십시오.

Get Credential Contents (get)

지정한 credential의 내용을 가져와 출력합니다.

사용법

지정한 security tag와 credential type에 일치하는 credential이 있으면 다음 command로 가져와 출력합니다.

cred get <SECTAG> <TYPE> <FORMAT>

Arguments

Argument설명
<SECTAG>가져올 credential의 security tag입니다. 0 이상의 integer를 사용할 수 있습니다.
<TYPE>가져올 credential type입니다. 유효한 값은 Credential Types 절을 참고하십시오.
<FORMAT>Credential을 반환할 retrieval format을 지정합니다. 유효한 값은 Storage/Retrieval Formats 절을 참고하십시오.

List Credentials (list)

Credential store의 TLS credential을 나열합니다.

사용법

사용 가능한 모든 credential을 나열합니다.

cred list

지정한 security tag의 credential을 모두 나열합니다.

cred list <SECTAG>

지정한 credential type을 모두 나열합니다.

cred list any <TYPE>

지정한 credential type과 security tag를 모두 만족하는 credential을 나열합니다.

cred list <SECTAG> <TYPE>

Arguments

Argument설명
<SECTAG>Optional입니다. 지정하면 해당 security tag의 credential만 나열합니다. 모든 tag를 허용하려면 any를 전달하거나 생략합니다. 그 밖에는 0 이상의 integer를 사용할 수 있습니다.
<TYPE>Optional입니다. 지정하면 해당 credential type만 나열합니다. 모든 type을 허용하려면 any를 전달하거나 생략합니다. 그 밖의 유효한 값은 Credential Types 절을 참고하십시오.

Output

Command는 일치하는 모든 credential을 다음 CSV-compatible format으로 출력합니다.

<SECTAG>,<TYPE>,<DIGEST>,<STATUS>

각 symbol의 의미는 다음과 같습니다.

Symbol값
<SECTAG>나열된 credential의 security tag입니다. 0 이상의 integer입니다.
<TYPE>나열된 credential의 credential type short-code입니다. 자세한 내용은 Credential Types 절을 참고하십시오.
<DIGEST>Credential 내용을 나타내는 string digest입니다. 정확한 성격은 storage backend에 따라 달라질 수 있지만, 현재 모든 backend에서는 raw credential 내용의 SHA-256 hash를 base64 encoding한 값입니다. 따라서 본질적으로 같은 credential도 storage format이 다르면 digest가 달라집니다.
<STATUS>나열된 credential의 digest 생성 성공·실패를 나타냅니다. 성공하면 0이고 실패하면 storage backend별 negative error code입니다. 0이 아닌 status가 있는 line은 error formatting으로 출력됩니다.

List 출력 뒤에는 찾은 credential의 최종 summary를 다음 형식으로 출력합니다.

<N> credentials found.

<N>은 찾은 credential 수이며 하나도 없으면 0입니다.

Credential Types

다음 keyword는 대소문자와 관계없이 credential type을 지정하는 데 사용할 수 있습니다.

Keyword(s)의미
CA_CERT, CA신뢰하는 CA certificate
SERVER_CERT, SELF_CERT, CLIENT_CERT, CLIENT, SELF, SERVSelf 또는 server certificate
PRIVATE_KEY, PKPrivate key
PRE_SHARED_KEY, PSKPre-shared key
PRE_SHARED_KEY_ID, PSK_IDPre-shared key ID

Storage/Retrieval Formats

TLS credentials module은 저장된 credential을 임의의 binary buffer로 취급합니다.

TLS Credentials shell은 이 buffer를 shell에서 제공하고 나중에 가져오기 쉽도록 네 가지 format을 제공합니다. Keyword는 대소문자를 구분하지 않습니다.

Keyword의미저장 시 동작 (cred add)가져올 때 동작 (cred get)
BINShell에서는 base64로 처리하고 NULL terminator 없이 저장합니다.Shell 입력을 base64에서 raw binary로 decode한 뒤 저장하며 terminator를 붙이지 않습니다.저장 data를 base64로 encode한 뒤 출력합니다.
BINTShell에서는 base64로 처리하고 NULL terminator와 함께 저장합니다.Shell 입력을 base64에서 raw binary로 decode하고 NULL terminator를 붙인 뒤 저장합니다.저장 data에서 NULL terminator를 제거한 뒤 base64로 encode해 출력합니다.
STRShell에서는 literal string으로 처리하고 NULL terminator 없이 저장합니다.입력 text를 작성한 그대로 NULL terminator 없이 저장합니다.저장 data를 text로 출력하며 printable하지 않은 character는 ?로 출력합니다.
STRTShell에서는 literal string으로 처리하고 NULL terminator와 함께 저장합니다.입력 text를 작성한 그대로 NULL terminator와 함께 저장합니다.저장 data에서 NULL terminator를 제거한 뒤 text로 출력하며 printable하지 않은 character는 ?로 출력합니다.

BIN format은 base64가 생각할 수 있는 모든 binary buffer를 encode할 수 있으므로 모든 credential type을 설치할 수 있습니다. 나머지 세 format은 특별한 use case의 편의를 위해 제공합니다.

예를 들면 다음과 같습니다.

  • 출력 가능한 pre-shared key는 STR을 사용해 미리 encoding하지 않고 PSK를 입력합니다. 그러면 NULL terminator 없이 저장됩니다.
  • DER format X.509 certificate 또는 printable하지 않은 PSK 같은 raw-binary credential은 binary를 base64로 encode하고 BIN format을 사용합니다.
  • PEM format X.509 certificate 또는 certificate chain은 newline과 ----BEGIN X ----/----END X---- marker를 포함한 전체 PEM string을 base64로 encode한 뒤 BINT format을 사용해 저장 string이 NULL-terminated가 되도록 합니다. Zephyr shell이 multi-line string을 지원하지 않기 때문에 필요합니다. Base64를 쓰지 않는다면 이 목적으로 STRT를 사용할 수 있습니다. NULL terminator를 base64에 직접 encode했다면 BIN도 사용할 수 있습니다.

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.