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