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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:00:45+00:00 2026-05-30T13:00:45+00:00

I wonder if I am missing some piece of code in this example.I am

  • 0

I wonder if I am missing some piece of code in this example.I am getting compile-time error on certHeader,certFooter in this class.IF someone can give me a brief idea about it that will be helpful.or IF some one has a better example on certificate parser that will be helpful.
I am using this example to parse a certificate.

try 
{ 
    String abc = "-----BEGIN CERTIFICATE-----\n" + "ALneIwerZ5Nu+z1Yjvdco9sOHfkhYW4nL+FIlGDGIS +YsyevB8YN2hBnog7gtQ6PB+sVF6o/1UdU\n" + // lines deleted for brevity "rchFUEChHZ5G7AAk02K7/iyqITc/IPNHHpilTg/NB6QhF9s=\n" + "-----END CERTIFICATE-----";

int headerIndex = abc.indexOf(certHeader); 
    if (headerIndex == -1) 
    {
        throw new CertificateParsingException("cannot find BEGIN CERTIFICATE");
        }
    int startIndex = headerIndex + certHeader.length();

int endIndex = abc.indexOf(certFooter);
if (endIndex == -1) 
{
    throw new CertificateParsingException("cannot find END CERTIFICATE"); }

String cert = abc.substring(startIndex, endIndex);
byte[] certBytes = cert.getBytes();

InputStream in = new Base64InputStream(new ByteArrayInputStream(certBytes));

CertificateFactory certFact = CertificateFactory.getInstance ("X.509");
Certificate certGen = certFact.generateCertificate(in);
X509Certificate x509 = (X509Certificate)
certGen; 
}
catch (Exception e) 
{ 
    Log.e("testapp", "exception: " + e.getMessage());
    } 
  • 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-05-30T13:00:46+00:00Added an answer on May 30, 2026 at 1:00 pm

    certHeader and certFooter are supposed to be int variables. From what you’ve shown us, it doesn’t look like you’ve declared them anywhere.

    From the String.indexOf documentation:

    Returns the index within this string of the first occurrence of the
    specified character. If a character with value ch occurs in the
    character sequence represented by this String object, then the index
    (in Unicode code units) of the first such occurrence is returned. For
    values of ch in the range from 0 to 0xFFFF (inclusive), this is the
    smallest value k such that:

    this.charAt(k) == ch
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just wonder, why some enums are missing on the TimeUnit class of Java?
I had hard time to figure out why I've been getting unknown action error
I have some code that I want to build. The code uses boost::ptr_map class
wonder what's wrong <table id=tblDomainVersion> <tr> <td>Version</td> <td>No of sites</td> </tr> <tr> <td class=clsversion>1.25</td>
wonder whether someone can help me with the following one... I have a struct
wonder if someone could help me with a little problem. I have session values
I wonder whether someone may be able to help me please. Firstly apologies as
I wonder whether someone has an idea for how to count combinations like the
Is there any good practice to avoid your jQuery code silently fail? For example:
I wonder if I should use the CAS protocol or OAuth + some authentication

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.