Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8262863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:53:53+00:00 2026-06-08T03:53:53+00:00

I am trying to create some helper methods to create (and sign) CSR, self

  • 0

I am trying to create some helper methods to create (and sign) CSR, self signed certificates etc… I already had some methods implemented with now-deprecated functionality.
In the interest of keeping up with the latest, I have upgraded bouncycastle to 1.47 which seems to be largely different and I was wondering two things:

1) I can’t seem to track down a concise list of examples. Due to the added verbosity of the code now necessary to accomplish similar things as before, this would be very welcome.

2) It seems unreasonably hard to work with bouncycastle while mixing in classic JCE stuff, at least much more so then before. Is there a reason for this?

As an example of the latter, take the generation of a csr, it used to be as simple as doing this:

org.bouncycastle.jce.PKCS10CertificationRequest request = new org.bouncycastle.jce.PKCS10CertificationRequest(type.toString(), subject, pair.getPublic(), null, pair.getPrivate());

Where subject is a “javax.security.auth.x500.X500Principal”, the private & public key stem from a general “java.security.KeyPair” etc.

Now I have something like:

public byte[] generatePKCS10(KeyPair pair, SignatureType type, X500Principal subject) throws IOException {
    PKCS10CertificationRequestBuilder builder = new PKCS10CertificationRequestBuilder(
        new X500Name(subject.getName()),
        SubjectPublicKeyInfo.getInstance(pair.getPublic())
    );
    AlgorithmIdentifier sigAlgId = new DefaultSignatureAlgorithmIdentifierFinder().find(type.toString());
    AlgorithmIdentifier digAlgId = new DefaultDigestAlgorithmIdentifierFinder().find(sigAlgId);
    AsymmetricKeyParameter keyParam = PrivateKeyFactory.createKey(pair.getPrivate().getEncoded());
    try {
        ContentSigner signer = new BcRSAContentSignerBuilder(sigAlgId, digAlgId).build(keyParam);
        PKCS10CertificationRequest csr = builder.build(signer);
        ContentVerifierProvider verifier = new JcaContentVerifierProviderBuilder().setProvider(new BouncyCastleProvider()).build(pair.getPublic());
        csr.isSignatureValid(verifier);
        return csr.getEncoded();
    }
    catch (OperatorCreationException e) {
        throw new IOException(e);
    }
    catch (PKCSException e) {
        throw new IOException(e);
    }
}

Is there a whole host of easy conversion utilities or overloaded methods or JCE-specific implementations that I’m missing? It does not help that a lot of google-searches highlight old (read: deprecated) ways of doing things.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T03:53:55+00:00Added an answer on June 8, 2026 at 3:53 am

    I stumbled upon a JCE-compliant solution shortly after posting this. It seems quite a few of their classes have a JCA-specific extension which handles all the necessary conversion. For example “X509v1CertificateBuilder” can be instantiated as “new JcaX509v1CertificateBuilder()” which takes JCE parameters instead of bouncycastle-specific ones.

    For the example above:

    PKCS10CertificationRequestBuilder builder = new JcaPKCS10CertificationRequestBuilder(
        subject,
        pair.getPublic()
    );
    

    I hope this pattern holds…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create some capacity planning reports and one of the requrements
So I'm trying to create some graphs using Core Plot, but for the following
I am trying to create some reusable components in Silverlight2 . The difficulty comes
I am trying to create some charts of data (eg http://www.amibroker.com/ ). Is there
I am trying to create some rules and facts on a certain situation. The
I am trying to create some global variables in a firefox extension. In my
I am trying to create some script variables in T-SQL as follows: /* Deployment
I am trying to create some dynamic html out of some data from db.
I'm trying to create some tool for testing WCF services. I'm aware of such
I am trying to create some simple polygons in openGL3.3. I have 2 types

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.