Skip to content

Can you provide an example of how to use PKCS#11 interface to connect MQTT on Android9.0? #242

@Runxing123

Description

@Runxing123

Confirm by changing [ ] to [x] below:

Platform/OS/Hardware/Device
Android9.0

Describe the question

public class TlsContextPkcs11Options extends CrtResource {
  Pkcs11Lib pkcs11Lib;
  String userPin;
  Long slotId;
  String tokenLabel;
  String privateKeyObjectLabel;
  String certificateFilePath;
  String certificateFileContents;

  public TlsContextPkcs11Options(Pkcs11Lib pkcs11Lib) {
    this.addReferenceTo(pkcs11Lib);
    this.pkcs11Lib = pkcs11Lib;
  }

  public TlsContextPkcs11Options withUserPin(String pin) {
    this.userPin = pin;
    return this;
  }

  public TlsContextPkcs11Options withSlotId(long slotId) {
    this.slotId = slotId;
    return this;
  }

  public TlsContextPkcs11Options withTokenLabel(String label) {
    this.tokenLabel = label;
    return this;
  }

  public TlsContextPkcs11Options withPrivateKeyObjectLabel(String label) {
    this.privateKeyObjectLabel = label;
    return this;
  }

  public TlsContextPkcs11Options withCertificateFilePath(String path) {
    this.certificateFilePath = path;
    return this;
  }

  public TlsContextPkcs11Options withCertificateFileContents(String contents) {
    this.certificateFileContents = contents;
    return this;
  }

  protected void releaseNativeHandle() {
  }

  protected boolean canReleaseReferencesImmediately() {
    return true;
  }
}

Which fields are definitely required in the TlsContextPkcs11Options instance? Can you help provide a sample code?

Metadata

Metadata

Assignees

No one assigned

    Labels

    guidanceQuestion that needs advice or information.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions