Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing Master List with Spongy castle return Null Public Key #61

Open
nadine199177 opened this issue Feb 7, 2024 · 0 comments
Open

Comments

@nadine199177
Copy link

nadine199177 commented Feb 7, 2024

I am trying to parse the master list using the code below in this link:

Github MasterList Parser

Using this code (Bouncy Castle) I am getting the error below:


        try {
            Enumeration<?> derObjects = ASN1Sequence.getInstance(octets).getObjects();
            CertificateFactory cf = CertificateFactory.getInstance("X.509","BC");

            while (derObjects.hasMoreElements()) {
                ASN1Integer version = (ASN1Integer)derObjects.nextElement(); //Should be 0
//              if (version!=0) throw Exception; //TODO Exception model
                ASN1Set certSet = ASN1Set.getInstance(derObjects.nextElement());

                Enumeration<Certificate> certs = certSet.getObjects();
                while (certs.hasMoreElements()) {
                    org.bouncycastle.asn1.x509.Certificate certAsASN1Object = org.bouncycastle.asn1.x509.Certificate.getInstance(certs.nextElement());
                    cscaCerts.add(cf.generateCertificate(new ByteArrayInputStream(certAsASN1Object.getEncoded())));
                }

            }
java.security.NoSuchAlgorithmException: The BC provider no longer provides an implementation for CertificateFactory.X.509. Please see https://android-developers.googleblog.com/2018/03/cryptography-changes-in-android-p.html for more details.

Using Spongy Castle I am getting null in public key (in object java.security.cert within the list cscaCerts) NO error but after parsing null public key presented.

  try {
            Enumeration<?> derObjects = ASN1Sequence.getInstance(octets).getObjects();

            while (derObjects.hasMoreElements()) {
                ASN1Integer version = (ASN1Integer) derObjects.nextElement(); //Should be 0
//              if (version!=0) throw Exception; //TODO Exception model
                ASN1Set certSet = ASN1Set.getInstance(derObjects.nextElement());

                Enumeration<Certificate> certs = certSet.getObjects();
                while (certs.hasMoreElements()) {
                    org.spongycastle.asn1.x509.Certificate certAsASN1Object = org.spongycastle.asn1.x509.Certificate.getInstance(certs.nextElement());
                    cscaCerts.add(new X509CertificateObject(certAsASN1Object));
                }

            }

Public Key: null

implementation 'com.madgag.spongycastle:prov:1.58.0.0'
implementation 'com.madgag.spongycastle:bcpkix-jdk15on:1.58.0.0'
targetSdk 32 Gradle jdk: 17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant