pub struct VapidKey { /* private fields */ }Expand description
The collector’s VAPID key pair (RFC 8292): a P-256 key generated on the
first start and kept in vapid.key (kernel spec §6). Every push
subscription is bound to its public key, so the file is never replaced:
one that cannot be read stops the start (decision 1). The private key
leaves this type only as signatures.
Implementations§
Source§impl VapidKey
impl VapidKey
Sourcepub fn generate() -> Self
pub fn generate() -> Self
A fresh key held only in memory: for tests, and for a collector that has not loaded its file yet.
Sourcepub fn load_or_create(dir: &Path) -> Result<Self>
pub fn load_or_create(dir: &Path) -> Result<Self>
The key in dir/vapid.key, created 0600 when there is none. A file
there that is not a private, regular, 32-byte P-256 key is an error,
never replaced (decision 1).
Sourcepub fn public_key(&self) -> &str
pub fn public_key(&self) -> &str
The public key, base64url: GET /api/push/vapid.
The Authorization header of a push to endpoint at now (RFC 8292
§3): vapid t=<token>, k=<public key>. The token names the
endpoint’s origin (audience), subject (subject) when there is
one, and an expiry VAPID_TOKEN_SECS ahead.