Changeset 4257

Show
Ignore:
Timestamp:
08/19/08 17:19:45 (3 months ago)
Author:
martin
Message:

certificate based gateway authentication
prototype PSK user authentication with auth-dialog

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/charon/plugins/nm/Makefile.am

    r4238 r4257  
    66plugin_LTLIBRARIES = libstrongswan-nm.la 
    77libstrongswan_nm_la_SOURCES = \ 
    8   nm_plugin.h nm_plugin.c nm_service.h nm_service.c  
     8  nm_plugin.h nm_plugin.c nm_service.h nm_service.c nm_creds.h nm_creds.c 
    99libstrongswan_nm_la_LDFLAGS = -module 
    1010libstrongswan_nm_la_LIBADD = ${nm_LIBS} 
  • trunk/src/charon/plugins/nm/gnome/Makefile.am

    r4241 r4257  
    11AUTOMAKE_OPTIONS = foreign 
    22 
    3 SUBDIRS = properties po 
     3SUBDIRS = properties auth-dialog po 
    44 
    55dbusservicedir = $(sysconfdir)/dbus-1/system.d 
  • trunk/src/charon/plugins/nm/gnome/configure.in

    r4241 r4257  
    117117Makefile 
    118118properties/Makefile 
     119auth-dialog/Makefile 
    119120po/Makefile.in 
    120121]) 
  • trunk/src/charon/plugins/nm/gnome/properties/nm-strongswan-dialog.glade

    r4241 r4257  
    7979                    </child> 
    8080                    <child> 
    81                       <widget class="GtkButton" id="certificate-button"> 
    82                         <property name="visible">True</property> 
    83                         <property name="can_focus">True</property> 
    84                         <property name="receives_default">True</property> 
    85                         <property name="has_tooltip">True</property> 
    86                         <property name="tooltip_text">A trusted certificate to use to authenticate the Gateway.</property> 
    87                         <property name="label" translatable="yes">(none)</property> 
    88                         <property name="response_id">0</property> 
    89                       </widget> 
    90                       <packing> 
    91                         <property name="left_attach">1</property> 
    92                         <property name="right_attach">2</property> 
    93                         <property name="top_attach">1</property> 
    94                         <property name="bottom_attach">2</property> 
    95                         <property name="y_options"></property> 
     81                      <widget class="GtkFileChooserButton" id="certificate-button"> 
     82                        <property name="visible">True</property> 
     83                      </widget> 
     84                      <packing> 
     85                        <property name="left_attach">1</property> 
     86                        <property name="right_attach">2</property> 
     87                        <property name="top_attach">1</property> 
     88                        <property name="bottom_attach">2</property> 
    9689                      </packing> 
    9790                    </child> 
     
    166159                      <widget class="GtkComboBox" id="method-combo"> 
    167160                        <property name="visible">True</property> 
    168                         <property name="sensitive">False</property> 
    169161                        <property name="has_tooltip">True</property> 
    170162                        <property name="tooltip_text">Authentication Method to use for authentication against the Gateway. </property> 
  • trunk/src/charon/plugins/nm/gnome/properties/nm-strongswan.c

    r4256 r4257  
    160160    g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (stuff_changed_cb), self); 
    161161 
     162    widget = glade_xml_get_widget (priv->xml, "certificate-button"); 
     163    if (!widget) 
     164        return FALSE; 
     165    value = g_hash_table_lookup (settings->data, "certificate"); 
     166    if (value) 
     167        gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), value); 
     168    g_signal_connect (G_OBJECT (widget), "selection-changed", G_CALLBACK (stuff_changed_cb), self); 
     169 
    162170    widget = glade_xml_get_widget (priv->xml, "user-entry"); 
    163171    if (!widget) 
     
    167175        gtk_entry_set_text (GTK_ENTRY (widget), value); 
    168176    g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (stuff_changed_cb), self); 
     177 
     178    widget = glade_xml_get_widget (priv->xml, "method-combo"); 
     179    if (!widget) 
     180        return FALSE; 
     181    gtk_combo_box_append_text (GTK_COMBO_BOX (widget), "EAP"); 
     182    value = g_hash_table_lookup (settings->data, "method"); 
     183    if (value) { 
     184        if (g_strcasecmp (value, "EAP") == 0) { 
     185            gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0); 
     186        } 
     187    } 
     188    g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (stuff_changed_cb), self); 
     189    if (gtk_combo_box_get_active (GTK_COMBO_BOX (widget)) == -1) 
     190    {   /* default to EAP */     
     191        gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0); 
     192    }    
    169193     
    170194    widget = glade_xml_get_widget (priv->xml, "virtual-check"); 
     
    236260    } 
    237261 
     262    widget = glade_xml_get_widget (priv->xml, "certificate-button"); 
     263    str = (char *) gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget)); 
     264    if (str) { 
     265        g_hash_table_insert (settings->data, g_strdup ("certificate"), g_strdup(str)); 
     266    } 
     267 
    238268    widget = glade_xml_get_widget (priv->xml, "user-entry"); 
    239269    str = (char *) gtk_entry_get_text (GTK_ENTRY (widget)); 
     
    242272    } 
    243273 
     274    widget = glade_xml_get_widget (priv->xml, "method-combo"); 
     275    str = (char *) gtk_combo_box_get_active_text (GTK_COMBO_BOX (widget)); 
     276    if (str) { 
     277        g_hash_table_insert (settings->data, g_strdup ("method"), g_strdup(str)); 
     278    } 
     279     
    244280    widget = glade_xml_get_widget (priv->xml, "virtual-check"); 
    245281    active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); 
  • trunk/src/charon/plugins/nm/nm_plugin.c

    r4238 r4257  
    1818#include "nm_plugin.h" 
    1919#include "nm_service.h" 
     20#include "nm_creds.h" 
    2021 
    2122#include <daemon.h> 
     
    3435    nm_plugin_t public; 
    3536     
     37    /** 
     38     * Glib main loop for a thread, handles DBUS calls 
     39     */ 
    3640    GMainLoop *loop; 
     41     
     42    /** 
     43     * credential set registered at the daemon 
     44     */ 
     45    nm_creds_t *creds; 
    3746}; 
    3847 
     
    4554    GMainLoop *loop; 
    4655 
    47     plugin = nm_strongswan_plugin_new(); 
     56    plugin = nm_strongswan_plugin_new(this->creds); 
    4857     
    4958    this->loop = loop = g_main_loop_new(NULL, FALSE); 
     
    6574        g_main_loop_quit(this->loop); 
    6675    } 
     76    charon->credentials->remove_set(charon->credentials, &this->creds->set); 
     77    this->creds->destroy(this->creds); 
    6778    free(this); 
    6879} 
     
    8495    } 
    8596     
     97    this->creds = nm_creds_create(); 
     98    charon->credentials->add_set(charon->credentials, &this->creds->set); 
     99     
    86100    charon->processor->queue_job(charon->processor,  
    87101         (job_t*)callback_job_create((callback_job_cb_t)run, this, NULL, NULL)); 
  • trunk/src/charon/plugins/nm/nm_service.c

    r4256 r4257  
    3737    ike_sa_t *ike_sa; 
    3838    NMVPNPlugin *plugin; 
     39    nm_creds_t *creds; 
    3940} NMStrongswanPluginPrivate; 
    4041 
     
    162163                         GError **err) 
    163164{ 
     165    nm_creds_t *creds; 
    164166    NMSettingVPN *settings; 
    165167    identification_t *user = NULL; 
     
    178180                                                        NM_TYPE_SETTING_VPN)); 
    179181     
    180     DBG2(DBG_CFG, "received NetworkManager connection: %s", 
     182    DBG1(DBG_CFG, "received NetworkManager connection: %s", 
    181183         nm_setting_to_string(NM_SETTING(settings))); 
    182184    str = g_hash_table_lookup(settings->data, "user"); 
     
    208210     
    209211    /** 
     212     * Register credentials 
     213     */ 
     214    creds = NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin)->creds; 
     215      
     216    str = g_hash_table_lookup(settings->data, "certificate"); 
     217    if (str) 
     218    { 
     219        certificate_t *cert; 
     220         
     221        cert = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509, 
     222                                  BUILD_FROM_FILE, str, BUILD_END); 
     223        creds->set_certificate(creds, cert); 
     224    } 
     225    str = g_hash_table_lookup(settings->data, "password"); 
     226    if (str) 
     227    { 
     228        creds->set_password(creds, str); 
     229    } 
     230     
     231    /** 
    210232     * Set up configurations 
    211233     */ 
     
    214236    peer_cfg = peer_cfg_create(CONFIG_NAME, 2, ike_cfg, user, 
    215237                    identification_create_from_encoding(ID_ANY, chunk_empty), 
    216                     CERT_SEND_IF_ASKED, UNIQUE_REPLACE, CONF_AUTH_PUBKEY
     238                    CERT_SEND_IF_ASKED, UNIQUE_REPLACE, CONF_AUTH_PSK
    217239                    0, 0, 1, /* EAP method, vendor, keyingtries */ 
    218240                    18000, 0, /* rekey 5h, reauth none */ 
     
    273295                             char **setting_name, GError **error) 
    274296{ 
     297    NMSettingVPN *settings; 
     298     
     299    settings = NM_SETTING_VPN(nm_connection_get_setting(connection, 
     300                                                        NM_TYPE_SETTING_VPN)); 
     301    if (!g_hash_table_lookup(settings->data, "password")) 
     302    { 
     303        *setting_name = NM_SETTING_VPN_SETTING_NAME; 
     304        return TRUE; 
     305    } 
    275306    return FALSE; 
    276307} 
     
    328359 * Object constructor 
    329360 */ 
    330 NMStrongswanPlugin *nm_strongswan_plugin_new(void) 
    331 
    332     return (NMStrongswanPlugin *)g_object_new ( 
    333                     NM_TYPE_STRONGSWAN_PLUGIN, NM_VPN_PLUGIN_DBUS_SERVICE_NAME, 
    334                     NM_DBUS_SERVICE_STRONGSWAN, NULL); 
    335 
    336  
     361NMStrongswanPlugin *nm_strongswan_plugin_new(nm_creds_t *creds) 
     362
     363    NMStrongswanPlugin *plugin = (NMStrongswanPlugin *)g_object_new ( 
     364                    NM_TYPE_STRONGSWAN_PLUGIN, 
     365                    NM_VPN_PLUGIN_DBUS_SERVICE_NAME, NM_DBUS_SERVICE_STRONGSWAN, 
     366                    NULL); 
     367     
     368    NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin)->creds = creds; 
     369     
     370    return plugin; 
     371
     372 
  • trunk/src/charon/plugins/nm/nm_service.h

    r4240 r4257  
    2828#include <nm-vpn-plugin.h> 
    2929 
     30#include "nm_creds.h" 
     31 
    3032#define NM_TYPE_STRONGSWAN_PLUGIN            (nm_strongswan_plugin_get_type ()) 
    3133#define NM_STRONGSWAN_PLUGIN(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_STRONGSWAN_PLUGIN, NMSTRONGSWANPlugin)) 
     
    4951GType nm_strongswan_plugin_get_type(void); 
    5052 
    51 NMStrongswanPlugin *nm_strongswan_plugin_new(void); 
     53NMStrongswanPlugin *nm_strongswan_plugin_new(nm_creds_t *creds); 
    5254 
    5355#endif /* NM_SERVICE_H_ */