Package org.zeromq
Class ZCert
java.lang.Object
org.zeromq.ZCert
The ZCert class provides a way to create and work with security
certificates for the ZMQ CURVE mechanism. A certificate contains a
public + secret key pair, plus metadata. It can be used as a
temporary object in memory, or persisted to disk.
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
.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
void
apply
(ZMQ.Socket socket) private void
byte[]
byte[]
private ZConfig
void
savePublic
(Writer writer) Saves the public key to a writer.savePublic
(String filename) Saves the public key to a file.void
saveSecret
(Writer writer) Saves the public and secret keys to a writer.saveSecret
(String filename) Saves the public and secret keys to a file.private ZConfig
void
void
-
Field Details
-
publicKey
private final byte[] publicKey -
secretKey
private final byte[] secretKey -
publicTxt
-
secretTxt
-
metadata
-
-
Constructor Details
-
ZCert
public ZCert() -
ZCert
-
ZCert
-
ZCert
public ZCert(byte[] publicKey, byte[] secretKey) -
ZCert
-
-
Method Details
-
assertKey
-
getPublicKey
public byte[] getPublicKey() -
getSecretKey
public byte[] getSecretKey() -
getPublicKeyAsZ85
-
getSecretKeyAsZ85
-
apply
-
getMetadata
-
setMeta
-
unsetMeta
-
getMeta
-
add
-
savePublic
Saves the public key to a file.This method will overwrite contents of existing file
- Parameters:
filename
- the path of the file to save the certificate into.- Returns:
- the saved file or null if dumped to the standard output
- Throws:
IOException
- if unable to save the file.
-
savePublic
Saves the public key to a writer.- Parameters:
writer
- the writer to save the certificate into.- Throws:
IOException
- if unable to dump the public configuration.
-
publicConfig
-
saveSecret
Saves the public and secret keys to a file.This method will overwrite contents of existing file
- Parameters:
filename
- the path of the file to save the certificate into.- Returns:
- the saved file or null if dumped to the standard output
- Throws:
IOException
- if unable to save the file.
-
saveSecret
Saves the public and secret keys to a writer.- Parameters:
writer
- the writer to save the certificate into.- Throws:
IOException
- if unable to dump the configuration.
-
secretConfig
-