Commit a5e36f23 authored by Patrick Dowler's avatar Patrick Dowler
Browse files

added constants for signature algorithm and key length (SHA256withRSA and 1024)

parent a672f006
Loading
Loading
Loading
Loading
+13 −12
Original line number Diff line number Diff line
@@ -44,15 +44,16 @@ import ca.nrc.cadc.auth.X509CertificateChain;
public class CertUtil
{
    
    public static final String DEFAULT_SIGNATURE_ALGORITHM = "SHA256WITHRSA";
    
    public static final int DEFAULT_KEY_LENGTH = 1024;

    /**
     * Method that generates an X509 proxy certificate
     * 
     * @param csr
     *            CSR for the certificate
     * @param lifetime
     *            lifetime of the certificate in SECONDS
     * @param chain
     *            certificate used to sign the proxy certificate
     * @param csr CSR for the certificate
     * @param lifetime lifetime of the certificate in SECONDS
     * @param chain certificate used to sign the proxy certificate
     * @return generated proxy certificate
     * @throws NoSuchAlgorithmException
     * @throws NoSuchProviderException
@@ -135,19 +136,19 @@ public class CertUtil
        }

        certGen.setPublicKey(csr.getPublicKey());
        certGen.setSignatureAlgorithm(issuerCert.getSigAlgName());
        // TODO: should be able to get signature algorithm from the csr, but... obtuse
        certGen.setSignatureAlgorithm(DEFAULT_SIGNATURE_ALGORITHM);

        // extensions
        // add ProxyCertInfo extension to the new cert

        certGen.addExtension(X509Extensions.KeyUsage, true, new KeyUsage(
                KeyUsage.digitalSignature | KeyUsage.keyEncipherment));
        certGen.addExtension(X509Extensions.KeyUsage, true, 
            new KeyUsage(KeyUsage.digitalSignature | KeyUsage.keyEncipherment));

        certGen.addExtension(X509Extensions.AuthorityKeyIdentifier,
            false, new AuthorityKeyIdentifierStructure(issuerCert));

        certGen.addExtension(X509Extensions.SubjectKeyIdentifier,

            false, new SubjectKeyIdentifierStructure(csr.getPublicKey("BC")));

        certGen.addExtension(X509Extensions.BasicConstraints, true,
+2 −2
Original line number Diff line number Diff line
@@ -105,8 +105,8 @@ public class CredPublicClient
            case HttpURLConnection.HTTP_CREATED:
                String location = connection.getHeaderField("Location");
                X509Certificate cert = generateV3Certificate(
                        readCSR(getEncodedCSR(location, userDN)
                                .getBytes()), days * 24 * 60 * 60);
                        readCSR(getEncodedCSR(location, userDN).getBytes()), 
                            days * 24 * 60 * 60);
                X509Certificate[] chain = createProxyCertChain(cert);
                putSignedCert(location, chain, userDN);