https://github.com/ddosolitary/sunpkcs11wrapper
A wrapper of SunPKCS11 which is compatible with Java 8
https://github.com/ddosolitary/sunpkcs11wrapper
android android-sdk java pkcs11 security yubikey
Last synced: about 2 months ago
JSON representation
A wrapper of SunPKCS11 which is compatible with Java 8
- Host: GitHub
- URL: https://github.com/ddosolitary/sunpkcs11wrapper
- Owner: DDoSolitary
- Created: 2020-08-07T04:55:32.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-01-17T13:49:22.000Z (over 5 years ago)
- Last Synced: 2025-01-22T00:44:01.387Z (over 1 year ago)
- Topics: android, android-sdk, java, pkcs11, security, yubikey
- Language: Java
- Homepage:
- Size: 66.4 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SunPKCS11Wrapper
Starting from OpenJDK 9, the `sun.security.pkcs11.SunPKCS11` class no longer provides the constructor accepting a configuration file, and instead, a new `configure()` method is added to the `java.security.Provider` class to support the same functionality. However, the `apksigner` tool from Android SDK doesn't support this new interface and will crash when trying to instantiate the `SunPKCS11` class.
This project provides a wrapper class with the old constructor interface, making `apksigner` compatible with OpenJDK 9 and later releases.
## Usage
1. [Download `SunPKCS11Wrapper.jar`](https://ddosolitary-builds.sourceforge.io/SunPKCS11Wrapper.jar) and copy it to `/build-tools//lib/`.
2. **Linux**:
In the last line of the file `/build-tools//apksigner` (which should be an `exec` command), replace `-jar "$jarpath"` with `-cp "$jarpath:$libdir/SunPKCS11Wrapper.jar" com.android.apksigner.ApkSignerTool`.
**Windows**:
In the last line of the file `/build-tools//apksigner.bat` (which should be a `call` command), replace `-jar "%jarpath%"` with `-cp "%jarpath%;%frameworkdir%\SunPKCS11Wrapper.jar" com.android.apksigner.ApkSignerTool`.
3. Run apksigner as usual, but pass `org.ddosolitary.pkcs11.SunPKCS11Wrapper` instead of `sun.security.pkcs11.SunPKCS11` to the `--provider-class` option.
For example:
```bash
apksigner sign \
--ks NONE \
--ks-key-alias \
--ks-type PKCS11
--provider-class org.ddosolitary.pkcs11.SunPKCS11Wrapper \
--provider-arg \
```
## See also
http://mail.openjdk.java.net/pipermail/jep-changes/2015-November/000219.html
https://issuetracker.google.com/issues/132333137