src/com/gitblit/authority/GitblitAuthority.java | ●●●●● patch | view | raw | blame | history | |
src/com/gitblit/authority/NewSSLCertificateDialog.java | ●●●●● patch | view | raw | blame | history | |
src/com/gitblit/wicket/GitBlitWebApp.properties | ●●●●● patch | view | raw | blame | history |
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(); src/com/gitblit/authority/NewSSLCertificateDialog.java
@@ -24,6 +24,7 @@ import java.util.Date; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JOptionPane; @@ -41,6 +42,7 @@ JDateChooser expirationDate; JTextField hostname; JCheckBox serveCertificate; boolean isCanceled = true; public NewSSLCertificateDialog(Frame owner, Date defaultExpiration) { @@ -60,6 +62,7 @@ expirationDate = new JDateChooser(defaultExpiration); hostname = new JTextField(20); serveCertificate = new JCheckBox(Translation.get("gb.serveCertificate"), true); JPanel panel = new JPanel(new GridLayout(0, 2, Utils.MARGIN, Utils.MARGIN)); @@ -68,6 +71,9 @@ panel.add(new JLabel(Translation.get("gb.expires"))); panel.add(expirationDate); panel.add(new JLabel("")); panel.add(serveCertificate); JButton ok = new JButton(Translation.get("gb.ok")); ok.addActionListener(new ActionListener() { @@ -124,6 +130,10 @@ return expirationDate.getDate(); } public boolean isServeCertificate() { return serveCertificate.isSelected(); } public boolean isCanceled() { return isCanceled; } src/com/gitblit/wicket/GitBlitWebApp.properties
@@ -435,3 +435,5 @@ gb.maxActivityCommitsDescription = maximum number of commits to contribute to the Activity page gb.noMaximum = no maximum gb.attributes = attributes gb.serveCertificate = serve https with this certificate gb.sslCertificateGeneratedRestart = Successfully generated new server SSL certificate for {0}.\nYou must restart Gitblit to use the new certificate.\n\nIf you are launching with the '--alias' parameter you will have to set that to ''--alias {0}''.