NPE when trying to generate a certificate

I'm getting the following error when trying to generate an X509 certificate on android

java.lang.NullPointerException: Attempt to invoke virtual method '' on a null object reference

Below is the code I use to achieve this:

            AssetFileDescriptor assetFileDescriptor = this.getAssets().openFd("cert.cer");
        FileDescriptor securityCertificate = assetFileDescriptor.getFileDescriptor();

        FileInputStream fin = new FileInputStream(securityCertificate);
        CertificateFactory cf = CertificateFactory.getInstance("X.509", "BC");
        X509Certificate certificate = (X509Certificate) cf.generateCertificate(fin);

The error seem to be happening on cf.generateCertificate(fin)