Class CaptureCertificateAuthority
java.lang.Object
com.shaft.capture.proxy.CaptureCertificateAuthority
Per-installation self-signed root certificate authority used to impersonate HTTPS hosts for
mobile API capture. Generated once per machine under
~/.shaft/capture-ca/ and reused on
every subsequent capture session; the private key is written with owner-only permissions and is
never logged, transmitted, or included in any capture artifact -- only the public certificate is
ever exported (for installation as a trusted CA on the device being captured).-
Constructor Summary
ConstructorsConstructorDescriptionLoads the per-installation CA from~/.shaft/capture-ca/, generating and persisting a new one if none exists yet.CaptureCertificateAuthority(Path directory) Loads (or generates) the CA under an explicit directory. -
Method Summary
Modifier and TypeMethodDescriptionReturns the CA's root certificate (public data only -- safe to export for device trust installation).Returns the directory this CA's key/certificate are persisted under.Exports the root CA certificate (public data only) as PEM text, for a user to install as a trusted CA on the mobile device/emulator being captured.issueLeafCertificate(String hostname, PublicKey leafPublicKey) Issues a short-lived leaf certificate forhostname, signed by this CA, impersonating that host for MITM interception.keyPair()Returns the CA's key pair.
-
Constructor Details
-
CaptureCertificateAuthority
public CaptureCertificateAuthority()Loads the per-installation CA from~/.shaft/capture-ca/, generating and persisting a new one if none exists yet.- Throws:
CaptureProxyException- if the CA could not be loaded or generated
-
CaptureCertificateAuthority
Loads (or generates) the CA under an explicit directory. Production code should prefer the no-arg constructor's shared per-machine~/.shaft/capture-cadirectory; this overload exists for tests and tools that must not touch that real, persistent, shared location and need an isolated (for example@TempDir-backed) directory instead.- Parameters:
directory- directory the CA key/cert are stored in
-
-
Method Details
-
certificate
Returns the CA's root certificate (public data only -- safe to export for device trust installation).- Returns:
- root CA certificate
-
keyPair
Returns the CA's key pair. The private key never leaves this process -- callers must not serialize or transmit it.- Returns:
- root CA key pair
-
directory
Returns the directory this CA's key/certificate are persisted under.- Returns:
- CA storage directory
-
exportCertificatePem
Exports the root CA certificate (public data only) as PEM text, for a user to install as a trusted CA on the mobile device/emulator being captured.- Returns:
- PEM-encoded root CA certificate
-
issueLeafCertificate
Issues a short-lived leaf certificate forhostname, signed by this CA, impersonating that host for MITM interception. The leaf never has CA capability (basic constraintsCA=false) so it cannot itself be used to mint further certificates.- Parameters:
hostname- the host being impersonated (recorded as the certificate's CN and DNS SAN)leafPublicKey- the public key the leaf certificate binds to- Returns:
- a certificate for
hostname, signed by this CA
-