~octy92/rapache/debian_logs

« back to all changes in this revision

Viewing changes to plugins/ssl/plugin.py

  • Committer: jason
  • Date: 2008-09-25 22:32:20 UTC
  • Revision ID: jason@jason-laptop-20080925223220-dkvznqqkcfzmo2o7
add chain to ssl

Show diffs side-by-side

added added

removed removed

Lines of Context:
114
114
        self.spinbutton_port = wtree.get_widget("spinbutton_port")
115
115
        self.entry_ssl_key_location = wtree.get_widget("entry_ssl_key_location")
116
116
        self.filechooserbutton_ssl_key = wtree.get_widget("filechooserbutton_ssl_key")
 
117
        self.entry_chain = wtree.get_widget("entry_chain")
 
118
        self.filechooserbutton_chain = wtree.get_widget("filechooserbutton_chain")
 
119
 
117
120
        signals = {
118
121
            "on_button_csr_clicked"                 : self.on_button_csr_clicked,
119
122
            "on_treeview_requests_row_activated"    : self.on_treeview_requests_row_activated,
120
123
            "on_button_import_clicked"              : self.on_button_import_clicked,
121
124
            "on_button_import_key_clicked"          : self.on_button_import_key_clicked,
122
 
            "on_button_key_reset_clicked"           : self.on_button_key_reset_clicked
 
125
            "on_button_key_reset_clicked"           : self.on_button_key_reset_clicked,
 
126
            "on_button_import_chain_clicked"        : self.on_button_import_chain_clicked
123
127
        }
124
128
        wtree.signal_autoconnect(signals)   
125
129
 
167
171
        return table_ssl, "SSL", pixbuf
168
172
 
169
173
 
 
174
    def on_button_import_chain_clicked(self, widget):
 
175
        path = self.filechooserbutton_chain.get_filename()
 
176
        
 
177
        if path:
 
178
            f = open(path, "r")
 
179
            text = f.read()
 
180
            f.close()
 
181
            
 
182
            timestamp = time.strftime("%y-%m-%d %H:%M:%S", time.localtime() )
 
183
 
 
184
            key_path = os.path.join("/etc/apache2/private/", os.path.basename(path) + ' ' + timestamp +'.ca-bundle' )
 
185
            
 
186
            if not self.core.current_server.command.sudo_exists(key_path):
 
187
                self.core.current_server.command.write_file(key_path, text)
 
188
                self.entry_chain.set_text(key_path)    
 
189
            else:
 
190
                md = gtk.MessageDialog(None, flags=0, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_CLOSE, message_format="A key with that filename already exists") 
 
191
                result = md.run()
 
192
                md.destroy()
 
193
 
 
194
 
 
195
 
170
196
    def on_button_import_key_clicked(self, widget):
171
197
        path = self.filechooserbutton_ssl_key.get_filename()
172
198
        
420
446
        else:
421
447
            self.entry_ssl_key_location.set_text(self.default_key)
422
448
        
 
449
        if vhost.config.SSLCertificateChainFile:
 
450
            self.entry_chain.set_text(vhost.config. SSLCertificateChainFile.value)
 
451
        else:
 
452
            self.entry_chain.set_text("")
 
453
        
423
454
        port = self.vhost.get_port()
424
455
        if port and not port == 80:
425
456
            self.spinbutton_port.set_value(port)
436
467
             vhost.config.SSLCertificateKeyFile.value = self.entry_ssl_key_location.get_text()
437
468
             vhost.set_port( self.spinbutton_port.get_value_as_int() )
438
469
             vhost.config.SSLCertificateFile.value = self.active_cert
 
470
             
 
471
             if self.entry_chain.get_text():
 
472
                vhost.config.SSLCertificateChainFile.value = self.entry_chain.get_text()
 
473
             elif vhost.config.SSLCertificateChainFile:
 
474
                del vhost.config.SSLCertificateChainFile
 
475
             
439
476
        else:
440
477
            if vhost.config.SSLEngine:
441
478
                del vhost.config.SSLEngine
444
481
                del vhost.config.SSLCertificateFile
445
482
                
446
483
            if vhost.config.SSLCertificateKeyFile:
447
 
                del vhost.config.SSLCertificateKeyFile             
448
 
             
 
484
                del vhost.config.SSLCertificateKeyFile   
 
485
                          
 
486
            if vhost.config.SSLCertificateChainFile:
 
487
                del vhost.config.SSLCertificateChainFile
 
488
                
449
489
            vhost.set_port(80)
450
490
 
451
491
        return True, ""