loudmouth/lm-ssl-generic.c
author Mikael Berthe <mikael@lilotux.net>
Mon, 25 Jan 2016 18:35:10 +0100
changeset 685 dfa02c1c7fda
parent 675 617e0120bb0f
child 690 7ccf2113ec5f
permissions -rw-r--r--
Bumped version to 1.5.2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
516
4dd3aa6b83e5 Change the tab width to 4 steps in the emacs headers
Mikael Hallendal <micke@imendio.com>
parents: 515
diff changeset
     1
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
     2
/*
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
     3
 * Copyright (C) 2003-2006 Imendio AB
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
     4
 *
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
     6
 * modify it under the terms of the GNU Lesser General Public License as
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
     7
 * published by the Free Software Foundation; either version 2 of the
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
     8
 * License, or (at your option) any later version.
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
     9
 *
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    13
 * Lesser General Public License for more details.
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    14
 *
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    15
 * You should have received a copy of the GNU Lesser General Public
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    16
 * License along with this program; if not, write to the
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    17
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    18
 * Boston, MA 02111-1307, USA.
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    19
 */
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    20
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    21
#include <config.h>
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    22
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    23
#include "lm-ssl.h"
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    24
#include "lm-ssl-base.h"
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    25
#include "lm-ssl-internals.h"
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    26
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 518
diff changeset
    27
LmSSLResponse
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    28
_lm_ssl_func_always_continue (LmSSL       *ssl,
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    29
                              LmSSLStatus  status,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    30
                              gpointer     user_data)
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    31
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    32
    return LM_SSL_RESPONSE_CONTINUE;;
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    33
}
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    34
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    35
/* Define the SSL functions as noops if we compile without support */
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    36
#ifndef HAVE_SSL
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    37
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    38
LmSSL *
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    39
_lm_ssl_new (const gchar    *expected_fingerprint,
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    40
             LmSSLFunction   ssl_function,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    41
             gpointer        user_data,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    42
             GDestroyNotify  notify)
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    43
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    44
    return NULL;
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    45
}
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    46
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    47
void
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    48
_lm_ssl_initialize (LmSSL *ssl)
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    49
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    50
    /* NOOP */
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    51
}
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    52
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    53
gboolean
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    54
_lm_ssl_begin (LmSSL        *ssl,
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    55
               gint          fd,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    56
               const gchar  *server,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    57
               GError      **error)
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    58
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    59
    return TRUE;
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    60
}
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    61
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    62
GIOStatus
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    63
_lm_ssl_read (LmSSL *ssl,
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    64
              gchar *buf,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    65
              gint   len,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    66
              gsize  *bytes_read)
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    67
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    68
    /* NOOP */
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    69
    *bytes_read = 0;
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    70
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    71
    return G_IO_STATUS_EOF;
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    72
}
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    73
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 518
diff changeset
    74
gboolean
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    75
_lm_ssl_send (LmSSL *ssl, const gchar *str, gint len)
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    76
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    77
    /* NOOP */
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    78
    return TRUE;
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    79
}
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 518
diff changeset
    80
void
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    81
_lm_ssl_close (LmSSL *ssl)
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    82
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    83
    /* NOOP */
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    84
}
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    85
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    86
void
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    87
_lm_ssl_free (LmSSL *ssl)
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    88
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    89
    /* NOOP */
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    90
}
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    91
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    92
#endif /* HAVE_SSL */
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    93
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    94
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    95
/**
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    96
 * lm_ssl_new:
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    97
 * @expected_fingerprint: The expected fingerprint. @ssl_function will be called if there is a mismatch. %NULL if you are not interested in this check.
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    98
 * @ssl_function: Callback called to inform the user of a problem during setting up the SSL connection and how to proceed. If %NULL is passed the default function that always continues will be used.
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    99
 * @user_data: Data sent with the callback.
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   100
 * @notify: Function to free @user_dataa when the connection is finished. %NULL if @user_data should not be freed.
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   101
 *
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 518
diff changeset
   102
 * Creates a new SSL struct, call #lm_connection_set_ssl to use it.
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   103
 *
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   104
 * Return value: A new #LmSSL struct.
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   105
 **/
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   106
LmSSL *
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   107
lm_ssl_new (const gchar    *expected_fingerprint,
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   108
            LmSSLFunction   ssl_function,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   109
            gpointer        user_data,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   110
            GDestroyNotify  notify)
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   111
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   112
    /* The implementation of this function will be different depending
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 518
diff changeset
   113
     * on which implementation is used
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   114
     */
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   115
    return _lm_ssl_new (expected_fingerprint,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   116
                        ssl_function, user_data, notify);
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   117
}
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   118
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   119
/**
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   120
 * lm_ssl_is_supported:
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   121
 *
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   122
 * Checks whether Loudmouth supports SSL or not.
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   123
 *
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   124
 * Return value: #TRUE if this installation of Loudmouth supports SSL, otherwise returns #FALSE.
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   125
 **/
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   126
gboolean
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   127
lm_ssl_is_supported (void)
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   128
{
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   129
#ifdef HAVE_SSL
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   130
    return TRUE;
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   131
#else
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   132
    return FALSE;
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   133
#endif
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   134
}
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   135
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   136
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   137
/**
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 518
diff changeset
   138
 * lm_ssl_get_fingerprint:
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   139
 * @ssl: an #LmSSL
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   140
 *
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   141
 * Returns the MD5 fingerprint of the remote server's certificate.
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 518
diff changeset
   142
 *
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   143
 * Return value: A 16-byte array representing the fingerprint or %NULL if unknown.
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   144
 **/
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   145
const gchar *
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   146
lm_ssl_get_fingerprint (LmSSL *ssl)
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   147
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   148
    g_return_val_if_fail (ssl != NULL, NULL);
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 518
diff changeset
   149
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   150
    return LM_SSL_BASE(ssl)->fingerprint;
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   151
}
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   152
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   153
/**
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   154
 * lm_ssl_ref:
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   155
 * @ssl: an #LmSSL
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 518
diff changeset
   156
 *
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   157
 * Adds a reference to @ssl.
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 518
diff changeset
   158
 *
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   159
 * Return value: the ssl
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   160
 **/
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   161
LmSSL *
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   162
lm_ssl_ref (LmSSL *ssl)
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   163
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   164
    g_return_val_if_fail (ssl != NULL, NULL);
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   165
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   166
    LM_SSL_BASE(ssl)->ref_count++;
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   167
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   168
    return ssl;
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   169
}
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   170
675
617e0120bb0f Add the new API to the reference documentation
Mikael Berthe <mikael@lilotux.net>
parents: 651
diff changeset
   171
/**
617e0120bb0f Add the new API to the reference documentation
Mikael Berthe <mikael@lilotux.net>
parents: 651
diff changeset
   172
 * lm_ssl_set_cipher_list:
617e0120bb0f Add the new API to the reference documentation
Mikael Berthe <mikael@lilotux.net>
parents: 651
diff changeset
   173
 * @ssl: an #LmSSL
617e0120bb0f Add the new API to the reference documentation
Mikael Berthe <mikael@lilotux.net>
parents: 651
diff changeset
   174
 * @cipher_list: list of ciphers
617e0120bb0f Add the new API to the reference documentation
Mikael Berthe <mikael@lilotux.net>
parents: 651
diff changeset
   175
 *
617e0120bb0f Add the new API to the reference documentation
Mikael Berthe <mikael@lilotux.net>
parents: 651
diff changeset
   176
 * Sets the list of availeble ciphers.
617e0120bb0f Add the new API to the reference documentation
Mikael Berthe <mikael@lilotux.net>
parents: 651
diff changeset
   177
 *
617e0120bb0f Add the new API to the reference documentation
Mikael Berthe <mikael@lilotux.net>
parents: 651
diff changeset
   178
 **/
650
a51209f570b6 Implemented lm_ssl_set_cipher_list
Frank Zschockelt <lm@freakysoft.de>
parents: 607
diff changeset
   179
void
a51209f570b6 Implemented lm_ssl_set_cipher_list
Frank Zschockelt <lm@freakysoft.de>
parents: 607
diff changeset
   180
lm_ssl_set_cipher_list (LmSSL       *ssl,
a51209f570b6 Implemented lm_ssl_set_cipher_list
Frank Zschockelt <lm@freakysoft.de>
parents: 607
diff changeset
   181
                        const gchar *cipher_list)
a51209f570b6 Implemented lm_ssl_set_cipher_list
Frank Zschockelt <lm@freakysoft.de>
parents: 607
diff changeset
   182
{
a51209f570b6 Implemented lm_ssl_set_cipher_list
Frank Zschockelt <lm@freakysoft.de>
parents: 607
diff changeset
   183
  _lm_ssl_base_set_cipher_list(LM_SSL_BASE(ssl), cipher_list);
a51209f570b6 Implemented lm_ssl_set_cipher_list
Frank Zschockelt <lm@freakysoft.de>
parents: 607
diff changeset
   184
}
a51209f570b6 Implemented lm_ssl_set_cipher_list
Frank Zschockelt <lm@freakysoft.de>
parents: 607
diff changeset
   185
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   186
/**
651
2990ee03cfa3 Implemented lm_ssl_set_ca
Frank Zschockelt <lm@freakysoft.de>
parents: 650
diff changeset
   187
 * lm_ssl_set_ca:
2990ee03cfa3 Implemented lm_ssl_set_ca
Frank Zschockelt <lm@freakysoft.de>
parents: 650
diff changeset
   188
 * @ssl: an #LmSSL
2990ee03cfa3 Implemented lm_ssl_set_ca
Frank Zschockelt <lm@freakysoft.de>
parents: 650
diff changeset
   189
 * @ca_path: path to a certificate or a directory containing certificates
2990ee03cfa3 Implemented lm_ssl_set_ca
Frank Zschockelt <lm@freakysoft.de>
parents: 650
diff changeset
   190
 *
2990ee03cfa3 Implemented lm_ssl_set_ca
Frank Zschockelt <lm@freakysoft.de>
parents: 650
diff changeset
   191
 * Sets a path to certificates which should be trusted.
2990ee03cfa3 Implemented lm_ssl_set_ca
Frank Zschockelt <lm@freakysoft.de>
parents: 650
diff changeset
   192
 *
2990ee03cfa3 Implemented lm_ssl_set_ca
Frank Zschockelt <lm@freakysoft.de>
parents: 650
diff changeset
   193
 **/
2990ee03cfa3 Implemented lm_ssl_set_ca
Frank Zschockelt <lm@freakysoft.de>
parents: 650
diff changeset
   194
void
2990ee03cfa3 Implemented lm_ssl_set_ca
Frank Zschockelt <lm@freakysoft.de>
parents: 650
diff changeset
   195
lm_ssl_set_ca (LmSSL *ssl, const gchar    *ca_path)
2990ee03cfa3 Implemented lm_ssl_set_ca
Frank Zschockelt <lm@freakysoft.de>
parents: 650
diff changeset
   196
{
2990ee03cfa3 Implemented lm_ssl_set_ca
Frank Zschockelt <lm@freakysoft.de>
parents: 650
diff changeset
   197
  _lm_ssl_base_set_ca_path(LM_SSL_BASE(ssl), ca_path);
2990ee03cfa3 Implemented lm_ssl_set_ca
Frank Zschockelt <lm@freakysoft.de>
parents: 650
diff changeset
   198
}
2990ee03cfa3 Implemented lm_ssl_set_ca
Frank Zschockelt <lm@freakysoft.de>
parents: 650
diff changeset
   199
2990ee03cfa3 Implemented lm_ssl_set_ca
Frank Zschockelt <lm@freakysoft.de>
parents: 650
diff changeset
   200
2990ee03cfa3 Implemented lm_ssl_set_ca
Frank Zschockelt <lm@freakysoft.de>
parents: 650
diff changeset
   201
/**
286
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   202
 * lm_ssl_use_starttls:
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   203
 * @ssl: an #LmSSL
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   204
 *
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   205
 * Set whether STARTTLS should be used.
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   206
 **/
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   207
void
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   208
lm_ssl_use_starttls (LmSSL *ssl,
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   209
                     gboolean use_starttls,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   210
                     gboolean require_starttls)
286
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   211
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   212
    LmSSLBase *base;
286
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   213
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   214
    base = LM_SSL_BASE (ssl);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   215
    base->use_starttls = use_starttls;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   216
    base->require_starttls = require_starttls;
286
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   217
}
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   218
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   219
/**
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   220
 * lm_ssl_get_use_starttls:
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   221
 *
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   222
 * Return value: TRUE is @ssl is configured to use STARTTLS.
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   223
 **/
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   224
gboolean
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   225
lm_ssl_get_use_starttls (LmSSL *ssl)
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   226
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   227
    LmSSLBase *base;
286
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   228
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   229
    base = LM_SSL_BASE (ssl);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   230
    return base->use_starttls;
286
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   231
}
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   232
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   233
/**
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   234
 * lm_ssl_get_require_starttls:
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   235
 *
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   236
 * Return value: TRUE if @ssl requires that STARTTLS succeed.
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   237
 **/
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   238
gboolean
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   239
lm_ssl_get_require_starttls (LmSSL *ssl)
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   240
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   241
    LmSSLBase *base;
286
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   242
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   243
    base = LM_SSL_BASE (ssl);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   244
    return base->require_starttls;
286
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   245
}
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   246
e0bcf40cbf5e add use_starttls and require_starttls members to LmSSLBase, plus corresponding access functions
Dafydd Harries <daf@rhydd.org>
parents: 137
diff changeset
   247
/**
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   248
 * lm_ssl_unref
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   249
 * @ssl: an #LmSSL
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 518
diff changeset
   250
 *
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   251
 * Removes a reference from @ssl. When no more references are present
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   252
 * @ssl is freed.
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   253
 **/
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 518
diff changeset
   254
void
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   255
lm_ssl_unref (LmSSL *ssl)
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   256
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   257
    LmSSLBase *base;
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 518
diff changeset
   258
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   259
    g_return_if_fail (ssl != NULL);
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 518
diff changeset
   260
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   261
    base = LM_SSL_BASE (ssl);
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   262
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   263
    base->ref_count --;
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 518
diff changeset
   264
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   265
    if (base->ref_count == 0) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   266
        if (base->data_notify) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   267
            (* base->data_notify) (base->func_data);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   268
        }
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 518
diff changeset
   269
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   270
        _lm_ssl_free (ssl);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   271
    }
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   272
}
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   273
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
   274