title: How to get certificate from pkcs7 file using bouncycastle?
body: <p>Hi, all! My problem is next: I have the .pkcs7 file which consists pre-packed CSR and I want to get CSR from it. How can I do it using bouncycastle?</p>
  
  <p>I tried use PEMReader, but it didn't work.</p>
  
  <p><pre><code>
      private void getCertificatesPKCS7File(String filename){
          try {
              certificates = new ArrayList();
  
              FileReader fileReader = new FileReader(filename);
              PEMReader pemReader = new PEMReader(fileReader);
             // Object obj = pemReader.readObject();
             // PKCS10CertificationRequest csr = (PKCS10CertificationRequest) obj;
              Object obj = pemReader.readPemObject().getContent();
              PKCS10CertificationRequest csr = new PKCS10CertificationRequest(obj);
  
              pemReader.close(); 
  
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  
  </code></pre></p>
  
  <p>Exception is next:</p>
  
  <p><pre><code>
  Exception in thread "main" java.lang.IllegalArgumentException: unknown object in factory: org.bouncycastle.asn1.ASN1ObjectIdentifier
      at org.bouncycastle.asn1.pkcs.CertificationRequestInfo.getInstance(Unknown Source)
      at org.bouncycastle.asn1.pkcs.CertificationRequest.(Unknown Source)
      at org.bouncycastle.jce.PKCS10CertificationRequest.(Unknown Source)
  </pre></code></p>
  
  <p>Thank's all!</p>