James Moger
2012-12-05 d63157b22bb8a7294080be29ca0fca8ecda96db9
src/com/gitblit/authority/GitblitAuthority.java
@@ -607,6 +607,7 @@
            }
            final Date expires = dialog.getExpiration();
            final String hostname = dialog.getHostname();
            final boolean serveCertificate = dialog.isServeCertificate();
            AuthorityWorker worker = new AuthorityWorker(GitblitAuthority.this) {
@@ -623,18 +624,32 @@
                  
                  // generate new SSL certificate
                  X509Metadata metadata = new X509Metadata(hostname, caKeystorePassword);
                  setMetadataDefaults(metadata);
                  metadata.notAfter = expires;
                  File serverKeystoreFile = new File(folder, X509Utils.SERVER_KEY_STORE);
                  X509Certificate cert = X509Utils.newSSLCertificate(metadata, caPrivateKey, caCert, serverKeystoreFile, GitblitAuthority.this);
                  return cert != null;
                  boolean hasCert = cert != null;
                  if (hasCert && serveCertificate) {
                     // update Gitblit https connector alias
                     Map<String, String> updates = new HashMap<String, String>();
                     updates.put(Keys.server.certificateAlias, metadata.commonName);
                     gitblitSettings.saveSettings(updates);
                  }
                  return hasCert;
               }
               @Override
               protected void onSuccess() {
                  if (serveCertificate) {
                     JOptionPane.showMessageDialog(GitblitAuthority.this,
                           MessageFormat.format(Translation.get("gb.sslCertificateGeneratedRestart"), hostname),
                           Translation.get("gb.newSSLCertificate"), JOptionPane.INFORMATION_MESSAGE);
                  } else {
                  JOptionPane.showMessageDialog(GitblitAuthority.this, 
                        MessageFormat.format(Translation.get("gb.sslCertificateGenerated"), hostname),
                        Translation.get("gb.newSSLCertificate"), JOptionPane.INFORMATION_MESSAGE);
               }
               }
            };
            
            worker.execute();