\r
#### fixes\r
\r
+- Set subjectAlternativeName on generated SSL cert if CN is an ip address (issue 170)\r
- Fixed incorrect links on history page for files not in the current/active commit (issue 166)\r
- Empty repository page failed to handle missing repository (issue 160)\r
- Fixed broken ticgit urls (issue 157)\r
}\r
return null;\r
}\r
+ \r
+ public static boolean isIpAddress(String address) {\r
+ if (StringUtils.isEmpty(address)) {\r
+ return false;\r
+ }\r
+ String [] fields = address.split("\\.");\r
+ if (fields.length == 4) {\r
+ // IPV4\r
+ for (String field : fields) {\r
+ try {\r
+ int value = Integer.parseInt(field);\r
+ if (value < 0 || value > 255) {\r
+ return false;\r
+ }\r
+ } catch (Exception e) {\r
+ return false;\r
+ }\r
+ }\r
+ }\r
+ // TODO IPV6?\r
+ return false;\r
+ }\r
}\r
import java.security.cert.X509Certificate;\r
import java.text.MessageFormat;\r
import java.text.SimpleDateFormat;\r
+import java.util.ArrayList;\r
import java.util.Arrays;\r
import java.util.Calendar;\r
import java.util.Date;\r
import java.util.HashMap;\r
import java.util.HashSet;\r
+import java.util.List;\r
import java.util.Map;\r
import java.util.Set;\r
import java.util.TimeZone;\r
certBuilder.addExtension(X509Extension.basicConstraints, false, new BasicConstraints(false));\r
certBuilder.addExtension(X509Extension.authorityKeyIdentifier, false, extUtils.createAuthorityKeyIdentifier(caCert.getPublicKey()));\r
\r
+ // support alternateSubjectNames for SSL certificates\r
+ List<GeneralName> altNames = new ArrayList<GeneralName>();\r
+ if (HttpUtils.isIpAddress(sslMetadata.commonName)) {\r
+ altNames.add(new GeneralName(GeneralName.iPAddress, sslMetadata.commonName)); \r
+ }\r
+ if (altNames.size() > 0) {\r
+ GeneralNames subjectAltName = new GeneralNames(altNames.toArray(new GeneralName [altNames.size()]));\r
+ certBuilder.addExtension(X509Extension.subjectAlternativeName, false, subjectAltName);\r
+ }\r
+\r
ContentSigner caSigner = new JcaContentSignerBuilder(SIGNING_ALGORITHM)\r
.setProvider(BC).build(caPrivateKey);\r
X509Certificate cert = new JcaX509CertificateConverter().setProvider(BC)\r