Java.lang.SecurityException:JCE cannot authenticate the provider BC

Source: Internet
Author: User

and x company docking data, their development language is Java, we are PHP, data communication between the two uses the encryption method is: Bouncycastle

Due to the limitations of this time, we do not use PHP to develop our own encryption algorithm, but instead of the other party's existing encryption package.

The specific ideas are:

1. Encapsulate the encryption method written by Java into a jar package;

2. Then call directly in PHP:exec ("Java-jar encrypt.jar") system command execution, implement encryption and decryption


There are 2 main problems encountered here:

1.cannot load Mian class

2. Error during commissioning: Java.lang.SecurityException:JCE cannot authenticate the provider BC


1. Execute the command "Java-jar Encrypt.jar" to run the JAR package error: Cannot load Mian class

This we in omnipotent Baidu and Google above also found a lot of information, have not solved, finally through the oldest oral precept way, asked a wily Java programmer, solved the bug

The method is:

After packaging into a jar package, you need to delete the. jar package file: Meta-inf/bckey before running execution: Java-jar. Dsa

As for what is this? This question I have asked the great God for everyone, the great God says the world is very big, he wants to see


2. Error during commissioning: Java.lang.SecurityException:JCE cannot authenticate the provider BC

This problem Baidu is not solved, is Google to solve, Google has an explanation is very clear complete blog, the original address: http://download.csdn.net/detail/tomliguocai/3945936

Worship the Great God

The following are the specific workarounds:

1. under Java, locate jre/lib/security/java.security and add a line of code:

Security.provider.9=org.bouncycastle.jce.provider.bouncycastleprovider//9 here, depending on the circumstances, you may be 10,11 ...

2. Add 2 expansion packs to the Jre/lib/ext directory: Bcprov-jdk15-135.jar Bcprov-jdk16-143.jar

3. Remove any of the BC extensions in your class path (this is not a step I use because there is no one in class path)

After these processing, finally saw the good encryption of ciphertext and digital signature, hahaha, happy~


Java.lang.SecurityException:JCE cannot authenticate the provider BC

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.