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 8089911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:33:28+00:00 2026-06-05T19:33:28+00:00

I have a PFX certificate which I use to read encrypted email in outlook.

  • 0

I have a PFX certificate which I use to read encrypted email in outlook.
I would like to read this email via Java.
I’ve managed to get a list of javax.mail.Message objects.
Whats the easiest way to decrypt these using my PFX key?

  • 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-05T19:33:30+00:00Added an answer on June 5, 2026 at 7:33 pm

    Using Bouncycastle and JavaMail:

    Store store = session.getStore("imaps");
    store.connect("imap.gmail.com", "user@gmail.com", "gmailPassword");
    System.out.println(store);
    
    Folder inbox = store.getFolder("MyFolder");
    inbox.open(Folder.READ_ONLY);
    Message messages[] = inbox.getMessages();
    
    for (Message message : messages) {
        KeyStore ks = KeyStore.getInstance("pkcs12");
    
        FileInputStream fis = new FileInputStream("c:\\key.pfx");
        String password = "pfxPassword";
    
        ks.load(fis, password.toCharArray());
        String alias = ks.aliases().nextElement();
    
        PrivateKey pKey = (PrivateKey) ks.getKey(alias, password.toCharArray());
        X509Certificate cert = (X509Certificate) ks.getCertificate(alias);
    
        RecipientId recId = new RecipientId();
    
        recId.setSerialNumber(cert.getSerialNumber());
        recId.setIssuer(cert.getIssuerX500Principal().getEncoded());
    
        SMIMEEnveloped m = new SMIMEEnveloped((MimeMessage) message);
        RecipientInformationStore recipients = m.getRecipientInfos();
        RecipientInformation recipient = recipients.get(recId);
    
        MimeBodyPart res = SMIMEUtil.toMimeBodyPart(recipient.getContent(pKey, ks.getProvider().getName()));
    
        MimeMultipart parts=(MimeMultipart) res.getContent();
    
        for (int i=0;i<parts.getCount();i++){
            BodyPart part=parts.getBodyPart(i);
            if (part.getContentType().contains("application/octet-stream")){
                //System.out.println(IOUtils.toString((InputStream) part.getContent()));
                ZipInputStream zin = new ZipInputStream((InputStream)part.getContent());
                ZipEntry entry;
                while((entry = zin.getNextEntry()) != null) {
                    System.out.println(IOUtils.toString(zin));
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a certificate generated via MakeCert. I want to use this certificate for
I have a file with the '.pfx' extension and a password to this certificate.
I have obtained a certificate by a trusted authority (have been given a .pfx
have written this little class, which generates a UUID every time an object of
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
I use InstallShield 2010 which requires a SPC/PFX and a PVK file to sign
I looked at this answer: Install a pfx certificate in a users store in
I have a string that's encrypted using some crypto classes in Java (RSA/ECB/PKCS1Padding) and
I have a method: require 'openssl' def extract_creds(data) pfx = OpenSSL::PKCS12.new(data) { :certificate =>
Have deployed numerous report parts which reference the same view however one of them

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.