konnect.curl.certificates.ascii_armor module

ASCII armor is a 7-bit safe encoding method for various types of data to be embedded in text

class ArmoredData(label: str, source: collections.abc.Sequence[SupportsIndex], headers: collections.abc.Sequence[tuple[str, str]] | None = None)[source]

Bases: bytes

Armored data is a labeled binary data object with optional headers

Common examples of armored data are X.509 certificates and private keys labeled as CERTIFICATE or PRIVATE KEY respectively.

encode_lines() collections.abc.Iterator[bytes][source]

Encode an ArmoredData instance and return a line iterator

The returned iterator yields the encoded field as LF terminated lines and is suitable for passing to typing.IO[bytes].writelines() or bytes.join().

classmethod extract(data: bytes | bytearray, *, with_unarmored: Literal[True]) collections.abc.Iterator[Self | str][source]
classmethod extract(data: bytes | bytearray, *, with_unarmored: Literal[False] = False) collections.abc.Iterator[Self]

Scan input and return an iterator that yields ArmoredData and unarmored lines

An unarmored line is anything outside of any field’s start and end lines and is yielded as Unicode strings if ‘with_unarmored’ is True. Note that unarmored lines are assumed to be ASCII or UTF-8 encoded.