Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

package com.codename1.backend.security.pki

Certificates, certification requests and key stores, read and written in the same Java on the JVM and in a native build.

  • Pem reads and writes PEM text; Certificate reads X.509 DER or PEM.
  • CertificateValidator validates a chain against trust anchors the application gives. There is no default trust store.
  • CertificationRequest creates and reads PKCS#10 requests.
  • Pkcs12 reads and writes .p12/.pfx key stores.
  • Keys are PKCS#8 DER (private) and SubjectPublicKeyInfo DER (public), the forms com.codename1.backend.Crypto signs, verifies and agrees keys with; Crypto.generateEcKey and Crypto.ecdh make and use P-256 and P-384 keys.

The algorithm profile, the same on every runtime:

UseSupportedRefused
Certificate and request signaturesRSA PKCS#1 v1.5 with SHA-256/384/512; RSASSA-PSS with SHA-256, MGF1-SHA-256, 32 byte salt; ECDSA P-256/SHA-256 and P-384/SHA-384SHA-1, MD5, other PSS parameters, ECDSA with a digest that does not match its curve
KeysRSA 2048 to 8192 bits; EC on P-256 and P-384Other curves, DSA, Ed25519
Key agreementECDH on P-256 and P-384X25519
PKCS#12 encryptionPBES2 with PBKDF2-HMAC-SHA-256 or -SHA-1 and AES-128/192/256-CBCRC2, 3DES (-legacy)
PKCS#12 integrityHMAC-SHA-1/256/384/512 MACPublic-key integrity, no MAC
EncodingDERBER indefinite lengths

Chain validation checks signatures, validity periods, basic constraints, key usage, path length, unknown critical extensions, and optionally the host name and extended key usage of the leaf. It does not check revocation, name constraints or certificate policies; a certificate that marks either of the last two critical is refused.

Types

class Asn1The DER this package reads and writes: a reader over definite-length encodings and the handful of writers the formats here need.
class CertificateAn X.509 v3 certificate, read from DER or PEM.
class CertificateExceptionA certificate, a chain or a key store that cannot be used: unreadable, outside the supported profile, or refused by validation.
class CertificateValidatorValidates a certificate chain against trust anchors the application names.
class CertificationRequestA PKCS#10 certification request: what a CA (an ACME server, a corporate CA, openssl x509 -req) is sent to issue a certificate for a key.
class DistinguishedNameAn X.500 distinguished name, as a certificate’s subject and issuer carry it.
class PemPEM, the base64 text form of DER that openssl reads and writes: one or more blocks between -----BEGIN <label>----- and -----END <label>-----.
class Pkcs12A PKCS#12 key store (.p12, .pfx) holding one private key and its certificate chain, or only certificates.
class SignedDataThe content and the certificates of a CMS SignedData structure (RFC 5652), the PKCS#7 envelope a .mobileprovision profile, a signed manifest or a detached signature file arrives in.