}\r
final Date expires = dialog.getExpiration();\r
final String hostname = dialog.getHostname();\r
-\r
+ final boolean serveCertificate = dialog.isServeCertificate();\r
+ \r
AuthorityWorker worker = new AuthorityWorker(GitblitAuthority.this) {\r
\r
@Override\r
\r
// generate new SSL certificate\r
X509Metadata metadata = new X509Metadata(hostname, caKeystorePassword);\r
+ setMetadataDefaults(metadata);\r
metadata.notAfter = expires;\r
File serverKeystoreFile = new File(folder, X509Utils.SERVER_KEY_STORE);\r
X509Certificate cert = X509Utils.newSSLCertificate(metadata, caPrivateKey, caCert, serverKeystoreFile, GitblitAuthority.this);\r
- return cert != null;\r
+ boolean hasCert = cert != null;\r
+ if (hasCert && serveCertificate) {\r
+ // update Gitblit https connector alias\r
+ Map<String, String> updates = new HashMap<String, String>();\r
+ updates.put(Keys.server.certificateAlias, metadata.commonName);\r
+ gitblitSettings.saveSettings(updates);\r
+ }\r
+ return hasCert;\r
}\r
\r
@Override\r
protected void onSuccess() {\r
- JOptionPane.showMessageDialog(GitblitAuthority.this, \r
+ if (serveCertificate) {\r
+ JOptionPane.showMessageDialog(GitblitAuthority.this, \r
+ MessageFormat.format(Translation.get("gb.sslCertificateGeneratedRestart"), hostname),\r
+ Translation.get("gb.newSSLCertificate"), JOptionPane.INFORMATION_MESSAGE);\r
+ } else {\r
+ JOptionPane.showMessageDialog(GitblitAuthority.this, \r
MessageFormat.format(Translation.get("gb.sslCertificateGenerated"), hostname),\r
Translation.get("gb.newSSLCertificate"), JOptionPane.INFORMATION_MESSAGE);\r
+ }\r
}\r
};\r
\r
import java.util.Date;\r
\r
import javax.swing.JButton;\r
+import javax.swing.JCheckBox;\r
import javax.swing.JDialog;\r
import javax.swing.JLabel;\r
import javax.swing.JOptionPane;\r
\r
JDateChooser expirationDate;\r
JTextField hostname;\r
+ JCheckBox serveCertificate;\r
boolean isCanceled = true;\r
\r
public NewSSLCertificateDialog(Frame owner, Date defaultExpiration) {\r
\r
expirationDate = new JDateChooser(defaultExpiration);\r
hostname = new JTextField(20);\r
+ serveCertificate = new JCheckBox(Translation.get("gb.serveCertificate"), true);\r
\r
JPanel panel = new JPanel(new GridLayout(0, 2, Utils.MARGIN, Utils.MARGIN));\r
\r
panel.add(new JLabel(Translation.get("gb.expires")));\r
panel.add(expirationDate);\r
\r
+ panel.add(new JLabel(""));\r
+ panel.add(serveCertificate);\r
+ \r
JButton ok = new JButton(Translation.get("gb.ok"));\r
ok.addActionListener(new ActionListener() {\r
public void actionPerformed(ActionEvent e) {\r
public Date getExpiration() {\r
return expirationDate.getDate();\r
}\r
- \r
+\r
+ public boolean isServeCertificate() {\r
+ return serveCertificate.isSelected();\r
+ }\r
+\r
public boolean isCanceled() {\r
return isCanceled;\r
}\r
gb.maxActivityCommits = max activity commits\r
gb.maxActivityCommitsDescription = maximum number of commits to contribute to the Activity page\r
gb.noMaximum = no maximum\r
-gb.attributes = attributes
\ No newline at end of file
+gb.attributes = attributes\r
+gb.serveCertificate = serve https with this certificate\r
+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}''.
\ No newline at end of file