]> source.dussan.org Git - gitblit.git/commitdiff
Cranked up signing algorithm from SHA1 to SHA512. This makes Opera P12 Import happy.
authorJames Moger <james.moger@gitblit.com>
Fri, 30 Nov 2012 21:17:04 +0000 (16:17 -0500)
committerJames Moger <james.moger@gitblit.com>
Fri, 30 Nov 2012 21:17:04 +0000 (16:17 -0500)
src/com/gitblit/utils/X509Utils.java

index 1d14489781308c43c92048f52f8ca98eb17f8567..7a402dac1428c88281855b9128ab1f998b136371 100644 (file)
@@ -111,6 +111,12 @@ public class X509Utils {
 \r
        private static final String BC = org.bouncycastle.jce.provider.BouncyCastleProvider.PROVIDER_NAME;\r
        \r
+       private static final int KEY_LENGTH = 2048;\r
+       \r
+       private static final String KEY_ALGORITHM = "RSA";\r
+       \r
+       private static final String SIGNING_ALGORITHM = "SHA512withRSA";\r
+       \r
        public static final boolean unlimitedStrength;\r
        \r
        private static final Logger logger = LoggerFactory.getLogger(X509Utils.class);\r
@@ -475,8 +481,8 @@ public class X509Utils {
         * @throws Exception\r
         */\r
        private static KeyPair newKeyPair() throws Exception {\r
-               KeyPairGenerator kpGen = KeyPairGenerator.getInstance("RSA", BC);\r
-               kpGen.initialize(2048, new SecureRandom());\r
+               KeyPairGenerator kpGen = KeyPairGenerator.getInstance(KEY_ALGORITHM, BC);\r
+               kpGen.initialize(KEY_LENGTH, new SecureRandom());\r
                return kpGen.generateKeyPair();\r
        }\r
        \r
@@ -550,7 +556,7 @@ public class X509Utils {
                        certBuilder.addExtension(X509Extension.basicConstraints, false, new BasicConstraints(false));\r
                        certBuilder.addExtension(X509Extension.authorityKeyIdentifier, false, extUtils.createAuthorityKeyIdentifier(caCert.getPublicKey()));\r
 \r
-                       ContentSigner caSigner = new JcaContentSignerBuilder("SHA256WithRSAEncryption")\r
+                       ContentSigner caSigner = new JcaContentSignerBuilder(SIGNING_ALGORITHM)\r
                                        .setProvider(BC).build(caPrivateKey);\r
                        X509Certificate cert = new JcaX509CertificateConverter().setProvider(BC)\r
                                        .getCertificate(certBuilder.build(caSigner));\r
@@ -589,7 +595,7 @@ public class X509Utils {
                try {\r
                        KeyPair caPair = newKeyPair();\r
                        \r
-                       ContentSigner caSigner = new JcaContentSignerBuilder("SHA1WithRSA").setProvider(BC).build(caPair.getPrivate());\r
+                       ContentSigner caSigner = new JcaContentSignerBuilder(SIGNING_ALGORITHM).setProvider(BC).build(caPair.getPrivate());\r
                        \r
                        // clone metadata\r
                        X509Metadata caMetadata = metadata.clone(CA_CN, metadata.password);\r
@@ -659,7 +665,7 @@ public class X509Utils {
                        X509v2CRLBuilder crlBuilder = new X509v2CRLBuilder(issuerDN, new Date());\r
                        \r
                        // build and sign CRL with CA private key\r
-                       ContentSigner signer = new JcaContentSignerBuilder("SHA1WithRSA").setProvider(BC).build(caPrivateKey);\r
+                       ContentSigner signer = new JcaContentSignerBuilder(SIGNING_ALGORITHM).setProvider(BC).build(caPrivateKey);\r
                        X509CRLHolder crl = crlBuilder.build(signer);\r
 \r
                        File tmpFile = new File(caRevocationList.getParentFile(), Long.toHexString(System.currentTimeMillis()) + ".tmp");\r
@@ -809,7 +815,7 @@ public class X509Utils {
                                certBuilder.addExtension(X509Extension.subjectAlternativeName, false, subjectAltName);\r
                        }\r
 \r
-                       ContentSigner signer = new JcaContentSignerBuilder("SHA1WithRSA").setProvider(BC).build(caPrivateKey);\r
+                       ContentSigner signer = new JcaContentSignerBuilder(SIGNING_ALGORITHM).setProvider(BC).build(caPrivateKey);\r
 \r
                        X509Certificate userCert = new JcaX509CertificateConverter().setProvider(BC).getCertificate(certBuilder.build(signer));\r
                        PKCS12BagAttributeCarrier bagAttr = (PKCS12BagAttributeCarrier)pair.getPrivate();\r