JcaX509CertificateConverter cannot find the required provider BC

bouncycastle, java

Solution

I just added an instance of the BouncyCastleProvider instead of BC and it worked perfectly. I am adding the answer for those who might be one day in the same situation:

X509Certificate crt=(X509Certificate)(new JcaX509CertificateConverter().setProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()).getCertificate(crthold));

Problem

I don't understand why BC is not being recognized as provider in the setProvider("BC"). I have downloaded the latest BouncyCastle http://www.bouncycastle.org/latest_releases.html (from 2013) and imported it successfully. However, when I run the following code: ``` X509Certificate crt=(X509Certificate)(new JcaX509CertificateConverter().setProvider("BC").getCertificate(crthold)); ``` I get an exception that provider `BC` was not found. Does anyone please has an idea on how this could be fixed? Below is the error message I am getting ``` org.bouncycastle.cert.jcajce.JcaX509CertificateConverter$ExCertificateException: cannot find required provider:no such provider: BC at org.bouncycastle.cert.jcajce.JcaX509CertificateConverter.getCertificate(Unknown Source) at client.ClientService.genCert(ClientService.java:399) ```

Original source