From 134a895dbf6db6b9784f165a3a577d6059949169 Mon Sep 17 00:00:00 2001
From: Mohamed MOUNIROU <mmounirou@MacBook-Pro-de-Mohamed.local>
Date: Tue, 04 Oct 2011 16:35:09 -0400
Subject: [PATCH] add tools to install giblet as service on linux based os

---
 src/com/gitblit/GitBlitServer.java |   33 ++++++++++++++++++++++++++++-----
 1 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/src/com/gitblit/GitBlitServer.java b/src/com/gitblit/GitBlitServer.java
index 92305fc..204ae4d 100644
--- a/src/com/gitblit/GitBlitServer.java
+++ b/src/com/gitblit/GitBlitServer.java
@@ -65,7 +65,7 @@
 
 	private static Logger logger;
 
-	public static void main(String[] args) {
+	public static void main(String... args) {
 		Params params = new Params();
 		JCommander jc = new JCommander(params);
 		try {
@@ -176,7 +176,7 @@
 				}
 				if (params.securePort < 1024 && !isWindows()) {
 					logger.warn("Gitblit needs to run with ROOT permissions for ports < 1024!");
-				}				
+				}
 				connectors.add(secureConnector);
 			} else {
 				logger.warn("Failed to find or load Keystore?");
@@ -237,7 +237,7 @@
 
 		// Setup the GitBlit context
 		GitBlit gitblit = GitBlit.self();
-		gitblit.configureContext(settings);
+		gitblit.configureContext(settings, true);
 		rootContext.addEventListener(gitblit);
 
 		try {
@@ -288,6 +288,9 @@
 	/**
 	 * Creates an https connector.
 	 * 
+	 * SSL renegotiation will be enabled if the JVM is 1.6.0_22 or later.
+	 * oracle.com/technetwork/java/javase/documentation/tlsreadme2-176330.html
+	 * 
 	 * @param keystore
 	 * @param password
 	 * @param useNIO
@@ -308,14 +311,31 @@
 			SslSocketConnector ssl = new SslSocketConnector();
 			connector = ssl;
 		}
-		connector.setAllowRenegotiate(false);
+		// disable renegotiation unless this is a patched JVM
+		boolean allowRenegotiation = false;
+		String v = System.getProperty("java.version");
+		if (v.startsWith("1.7")) {
+			allowRenegotiation = true;
+		} else if (v.startsWith("1.6")) {
+			// 1.6.0_22 was first release with RFC-5746 implemented fix.
+			if (v.indexOf('_') > -1) {
+				String b = v.substring(v.indexOf('_') + 1);
+				if (Integer.parseInt(b) >= 22) {
+					allowRenegotiation = true;
+				}
+			}
+		}
+		if (allowRenegotiation) {
+			logger.info("   allowing SSL renegotiation on Java " + v);
+		}
+		connector.setAllowRenegotiate(true);
 		connector.setKeystore(keystore.getAbsolutePath());
 		connector.setPassword(password);
 		connector.setPort(port);
 		connector.setMaxIdleTime(30000);
 		return connector;
 	}
-	
+
 	/**
 	 * Tests to see if the operating system is Windows.
 	 * 
@@ -376,6 +396,9 @@
 		}
 	}
 
+	/**
+	 * JCommander Parameters class for GitBlitServer.
+	 */
 	@Parameters(separators = " ")
 	private static class Params {
 

--
Gitblit v1.9.1