/usr/share/doc/libepc-doc/examples/server-credentials.c is in libepc-doc 0.4.4-3build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | /* Example of how to retreive SSL/TLS server credentials.
* This example (server-credentials.c) is in the public domain.
*/
#include <libepc/tls.h>
#include <libepc-ui/progress-window.h>
#include <gtk/gtk.h>
int
main (int argc,
char *argv[])
{
const gchar *hostname = (argc > 1 ? argv[1] : "localhost");
gchar *contents = NULL;
gchar *keyfile = NULL;
gchar *crtfile = NULL;
GError *error = NULL;
/* Initialize GTK+ and gnutls
*/
gnutls_global_init ();
g_thread_init (NULL);
gtk_init (&argc, &argv);
/* Show a progress window when generating new keys.
*/
epc_progress_window_install (NULL);
/* Retreive and display of server credentials.
*/
if (epc_tls_get_server_credentials (hostname, &crtfile, &keyfile, &error))
{
g_print ("private key file: %s\n", keyfile);
if (!g_file_get_contents (keyfile, &contents, NULL, &error))
goto out;
g_print ("%s", contents);
g_free (contents);
contents = NULL;
g_print ("server certificate file: %s\n", crtfile);
if (!g_file_get_contents (crtfile, &contents, NULL, &error))
goto out;
g_print ("%s", contents);
g_free (contents);
contents = NULL;
}
out:
/* Cleanup.
*/
if (error)
{
g_warning ("%s", error->message);
g_error_free (error);
}
g_free (keyfile);
g_free (crtfile);
return 0;
}
|