public class ZCert
extends java.lang.Object
To exchange certificates, send the public file via some secure route. Certificates are not signed but are text files that can be verified by eye.
Certificates are stored in the ZeroMQ Property Language format.
They have two sections, "metadata" and "curve".
The first contains a list of 'name = value' pairs, one per line.
Values may be enclosed in quotes.
The curve section has a 'public-key = key-value' and, for secret certificates, a
'secret-key = key-value' line.
The key-value is a Z85-encoded CURVE key
.
Modifier and Type | Field and Description |
---|---|
private ZMetadata |
metadata |
private byte[] |
publicKey |
private java.lang.String |
publicTxt |
private byte[] |
secretKey |
private java.lang.String |
secretTxt |
Constructor and Description |
---|
ZCert() |
ZCert(byte[] publicKey,
byte[] secretKey) |
ZCert(java.lang.String publicKey) |
ZCert(java.lang.String publicKey,
java.lang.String secretKey) |
ZCert(ZMQ.Curve.KeyPair keypair) |
Modifier and Type | Method and Description |
---|---|
private void |
add(ZMetadata meta,
ZConfig config) |
void |
apply(ZMQ.Socket socket) |
private void |
assertKey(int length,
int expected,
java.lang.String flavour) |
java.lang.String |
getMeta(java.lang.String key) |
ZMetadata |
getMetadata() |
byte[] |
getPublicKey() |
java.lang.String |
getPublicKeyAsZ85() |
byte[] |
getSecretKey() |
java.lang.String |
getSecretKeyAsZ85() |
private ZConfig |
publicConfig() |
java.io.File |
savePublic(java.lang.String filename)
Saves the public key to a file.
|
void |
savePublic(java.io.Writer writer)
Saves the public key to a writer.
|
java.io.File |
saveSecret(java.lang.String filename)
Saves the public and secret keys to a file.
|
void |
saveSecret(java.io.Writer writer)
Saves the public and secret keys to a writer.
|
private ZConfig |
secretConfig() |
void |
setMeta(java.lang.String key,
java.lang.String value) |
void |
unsetMeta(java.lang.String key) |
private final byte[] publicKey
private final byte[] secretKey
private final java.lang.String publicTxt
private final java.lang.String secretTxt
private final ZMetadata metadata
public ZCert()
public ZCert(java.lang.String publicKey)
public ZCert(ZMQ.Curve.KeyPair keypair)
public ZCert(byte[] publicKey, byte[] secretKey)
public ZCert(java.lang.String publicKey, java.lang.String secretKey)
private void assertKey(int length, int expected, java.lang.String flavour)
public byte[] getPublicKey()
public byte[] getSecretKey()
public java.lang.String getPublicKeyAsZ85()
public java.lang.String getSecretKeyAsZ85()
public void apply(ZMQ.Socket socket)
public ZMetadata getMetadata()
public void setMeta(java.lang.String key, java.lang.String value)
public void unsetMeta(java.lang.String key)
public java.lang.String getMeta(java.lang.String key)
public java.io.File savePublic(java.lang.String filename) throws java.io.IOException
This method will overwrite contents of existing file
filename
- the path of the file to save the certificate into.java.io.IOException
- if unable to save the file.public void savePublic(java.io.Writer writer) throws java.io.IOException
writer
- the writer to save the certificate into.java.io.IOException
- if unable to dump the public configuration.private ZConfig publicConfig()
public java.io.File saveSecret(java.lang.String filename) throws java.io.IOException
This method will overwrite contents of existing file
filename
- the path of the file to save the certificate into.java.io.IOException
- if unable to save the file.public void saveSecret(java.io.Writer writer) throws java.io.IOException
writer
- the writer to save the certificate into.java.io.IOException
- if unable to dump the configuration.private ZConfig secretConfig()