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

  • Home
  • SEARCH
  • 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 9252809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:02:54+00:00 2026-06-18T11:02:54+00:00

Good day. I need to save PKCS10 CSR in the external storage card. However,

  • 0

Good day.

I need to save PKCS10 CSR in the external storage card.

However, the following code shows an error

java.io.FileNotFoundException: /storage/sdcard0pkcs10.req: open failed: EROFS (Read-only file system)

While AndoidManifest.xml correctly includes

I feel that the problem is directory path since it shows 0 rather than /

package exam.blowfishcipher;

import java.io.FileWriter;
import java.io.OutputStreamWriter;
import java.security.*;
import org.spongycastle.jce.provider.BouncyCastleProvider;
import java.security.SecureRandom;

import javax.security.auth.x500.X500Principal;

import org.spongycastle.jce.PKCS10CertificationRequest;
import org.spongycastle.openssl.PEMWriter;

import android.os.Environment;
import android.util.*;
import android.widget.*;

public class PKCS10Generater
{
    static {
        Security.addProvider(new org.spongycastle.jce.provider.BouncyCastleProvider());
    }

    public static PKCS10CertificationRequest generateRequest(
            KeyPair pair)
            throws Exception

            {           
             return new PKCS10CertificationRequest(
                     "SHA256withRSA",
                     new X500Principal("CN=Test CA Certificate"),
                     //new X500Principal("CN=end"),
                     pair.getPublic(),
                     null,
                     pair.getPrivate());
            }

    public static void pemEncodeToFile(String filename, Object obj, char[] password) throws Exception{
        PEMWriter pw = new PEMWriter(new FileWriter(filename));
           Log.e("Position", "PEMWriter");
           if (password != null && password.length > 0) {
               pw.writeObject(obj, "DESEDE", password, new SecureRandom());
           } else {
               pw.writeObject(obj);
           }
           pw.flush();
           pw.close();
    }

    public static void reqGen() throws Exception
    {
        //create the keys
        Log.e("Position", "reqGen");
        KeyPair pair = Utils.generateRSAKeyPair();

        //modified 20130203
        PKCS10req pkcs10req = new PKCS10req();
        PKCS10CertificationRequest request = pkcs10req.generateRequest(pair);

        pemEncodeToFile(Environment.getExternalStorageDirectory()+"pkcs10.req", request, null);
        Log.e("Position", "getExternalStorage");
        PEMWriter pemWrt = new PEMWriter( new OutputStreamWriter(System.out));
        pemWrt.writeObject(request);
        pemWrt.close();

    }
}
  • 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-18T11:02:55+00:00Added an answer on June 18, 2026 at 11:02 am

    Just modify the line

    pemEncodeToFile(Environment.getExternalStorageDirectory()+"pkcs10.req", request, null);
    

    to

    pemEncodeToFile(Environment.getExternalStorageDirectory()+"/pkcs10.req", request, null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good day. I know that in order to save object state in Java I
Good day. I need to format a number in java. So far I have
Good day. I need to teach Windows CryptoAPI to encrypt the message with private
Good day, I have like 15 images I need to be buttons. I have
Good day, I have a requirement which i need to include a layout (actually
Good day, I need to find with a regular expression all matching elements in
Good day everyone. I need your skills with g++ to understand what's happening to
Good day! I am a newbie on creating database... I need to create a
Good day everyone I need to execute command on linux machine this command is
Good day, I need to extract portion of string which can looks like this:

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.