package com.pgl.ssdk;

import com.pgl.ssdk.AbstractC1464c;
import com.pgl.ssdk.ces.out.DungeonFlag;
import com.unity3d.ads.core.data.datasource.AndroidStaticDeviceInfoDataSource;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.BufferUnderflowException;
import java.nio.ByteBuffer;
import java.security.NoSuchAlgorithmException;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.List;
/* renamed from: com.pgl.ssdk.j  reason: case insensitive filesystem */
/* loaded from: classes6.dex */
public class C1471j {
    @DungeonFlag
    private static C1466e a(ByteBuffer byteBuffer) throws C1462a, NoSuchAlgorithmException, CertificateException {
        ByteBuffer a2 = C1468g.a(byteBuffer);
        a2.get(new byte[a2.remaining()]);
        a2.flip();
        a2.position(0);
        C1468g.a(a2);
        byte[] b = C1468g.b(C1468g.a(a2));
        try {
            Certificate generateCertificate = CertificateFactory.getInstance(AndroidStaticDeviceInfoDataSource.CERTIFICATE_TYPE_X509).generateCertificate(new ByteArrayInputStream(b));
            if (generateCertificate instanceof X509Certificate) {
                return new C1466e(String.valueOf(((X509Certificate) generateCertificate).getSubjectDN()), b);
            }
            return null;
        } catch (Exception unused) {
            return null;
        }
    }

    public static List<C1466e> a(InterfaceC1475n interfaceC1475n, AbstractC1464c.a aVar) throws IOException, C1467f {
        try {
            try {
                ByteBuffer a2 = C1468g.a(C1468g.a(interfaceC1475n, aVar, 1896449818).f4761a);
                if (a2.hasRemaining()) {
                    ArrayList arrayList = new ArrayList();
                    while (a2.hasRemaining()) {
                        try {
                            arrayList.add(a(C1468g.a(a2)));
                        } catch (NoSuchAlgorithmException | CertificateException unused) {
                        }
                    }
                    return arrayList;
                }
                return null;
            } catch (C1462a | BufferUnderflowException unused2) {
                return null;
            }
        } catch (C1470i e) {
            throw new C1467f(e.getMessage());
        }
    }
}
