mirror of
https://github.com/flatpak/flatpak.git
synced 2026-01-01 20:38:09 -05:00
Docker and podman can be configured to use mutual TLS authentication to the registry by dropping files into system-wide and user directories. Implement this in a largely compatible way. (Because of the limitations of our underlying libraries, we can't support multiple certificates within the same host config, but I don't expect anybody actually needs that.) The certs.d handling is extended so that certificates are separately looked up when downloading the look-aside index. This is mostly to simplify our tests, so we can use one web server for both - in actual operation, we expect the indexes to be unauthenticated. Also for testing purposes, FLATPAK_CONTAINER_CERTS_D is supported to override the standard search path. Co-authored-by: Sebastian Wick <sebastian.wick@redhat.com>
49 lines
1.1 KiB
C
49 lines
1.1 KiB
C
#include "libglnx.h"
|
|
#include "common/flatpak-utils-http-private.h"
|
|
#include "common/flatpak-utils-private.h"
|
|
|
|
int
|
|
main (int argc, char *argv[])
|
|
{
|
|
g_autoptr(FlatpakHttpSession) session = flatpak_create_http_session (PACKAGE_STRING);
|
|
g_autoptr(GError) error = NULL;
|
|
const char *url, *dest;
|
|
int flags = 0;
|
|
|
|
/* Avoid weird recursive type initialization deadlocks from libsoup */
|
|
g_type_ensure (G_TYPE_SOCKET);
|
|
|
|
if (argc == 3)
|
|
{
|
|
url = argv[1];
|
|
dest = argv[2];
|
|
}
|
|
else if (argc == 4 && g_strcmp0 (argv[1], "--compressed") == 0)
|
|
{
|
|
url = argv[2];
|
|
dest = argv[3];
|
|
flags |= FLATPAK_HTTP_FLAGS_STORE_COMPRESSED;
|
|
}
|
|
else
|
|
{
|
|
g_printerr ("Usage httpcache [--compressed] URL DEST\n");
|
|
return 1;
|
|
}
|
|
|
|
|
|
if (!flatpak_cache_http_uri (session,
|
|
url, NULL,
|
|
flags,
|
|
AT_FDCWD, dest,
|
|
NULL, NULL, NULL, &error))
|
|
{
|
|
g_print ("%s\n", error->message);
|
|
return 1;
|
|
}
|
|
else
|
|
{
|
|
g_print ("Server returned status 200: ok\n");
|
|
return 0;
|
|
}
|
|
}
|