keyfile: support writing certificates as blob inside the keyfile
authorThomas Haller <thaller@redhat.com>
Tue, 24 Feb 2015 21:22:14 +0000 (22:22 +0100)
committerThomas Haller <thaller@redhat.com>
Thu, 12 Mar 2015 17:16:58 +0000 (18:16 +0100)
commitc9a8764ad2805e22e1c556679e09636550374e21
treece9663acd234c8a9a3601e154db56a3926dbc979
parenta49680dacd73549169bfad1ba3bd94e1a7bb1ac1
keyfile: support writing certificates as blob inside the keyfile

keyfile should become our main import/export format. It is desirable,
that a keyfile can contain every aspect of a connection.

For blob certificates, the writer in core daemon would always write
them to a file and convert the scheme to path.
This behavior is not great for a (hyptetical) `nmcli connection export`
command because it would have to export them somehow outside of keyfile,
e.g. by writing them to temporary files.

Instead, if the write handler does not handle a certificate, use a
default implementation in nm_keyfile_write() which adds the blob inside
the keyfile.

Interestingly, keyfile reader already supported reading certificate
blobs. But this legacy format accepts the blob as arbitrary
binary without marking the format and without scheme prefix.
Instead of writing the binary data directly, write it with a new
uri scheme "data:;base64," and encode it in base64.

Also go through some lengths to make sure that whatever path
keyfile plugin writes, can be read back again. That is, because
keyfile writer preferably writes relative paths without prefix.
Add nm_keyfile_detect_unqualified_path_scheme() to encapsulate
the detection of pathnames without file:// prefix and use it to
check whether the path name must be fully qualified.
13 files changed:
.gitignore
libnm-core/nm-keyfile-internal.h
libnm-core/nm-keyfile-reader.c
libnm-core/nm-keyfile-writer.c
libnm-core/tests/Makefile.am
libnm-core/tests/certs/test-ca-cert.pem [new file with mode: 0644]
libnm-core/tests/certs/test-key-and-cert.pem [new file with mode: 0644]
libnm-core/tests/test-keyfile.c [new file with mode: 0644]
src/settings/plugins/keyfile/reader.c
src/settings/plugins/keyfile/tests/keyfiles/Test_Wired_TLS_Blob
src/settings/plugins/keyfile/tests/keyfiles/Test_Wired_TLS_Old
src/settings/plugins/keyfile/tests/test-keyfile.c
src/settings/plugins/keyfile/writer.c