Package org.zeromq

Class ZCert

java.lang.Object
org.zeromq.ZCert

public class ZCert extends Object
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 Details

    • publicKey

      private final byte[] publicKey
    • secretKey

      private final byte[] secretKey
    • publicTxt

      private final String publicTxt
    • secretTxt

      private final String secretTxt
    • metadata

      private final ZMetadata metadata
  • Constructor Details

    • ZCert

      public ZCert()
    • ZCert

      public ZCert(String publicKey)
    • ZCert

      public ZCert(ZMQ.Curve.KeyPair keypair)
    • ZCert

      public ZCert(byte[] publicKey, byte[] secretKey)
    • ZCert

      public ZCert(String publicKey, String secretKey)
  • Method Details

    • assertKey

      private void assertKey(int length, int expected, String flavour)
    • getPublicKey

      public byte[] getPublicKey()
    • getSecretKey

      public byte[] getSecretKey()
    • getPublicKeyAsZ85

      public String getPublicKeyAsZ85()
    • getSecretKeyAsZ85

      public String getSecretKeyAsZ85()
    • apply

      public void apply(ZMQ.Socket socket)
    • getMetadata

      public ZMetadata getMetadata()
    • setMeta

      public void setMeta(String key, String value)
    • unsetMeta

      public void unsetMeta(String key)
    • getMeta

      public String getMeta(String key)
    • add

      private void add(ZMetadata meta, ZConfig config)
    • savePublic

      public File savePublic(String filename) throws IOException
      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

      public void savePublic(Writer writer) throws IOException
      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

      private ZConfig publicConfig()
    • saveSecret

      public File saveSecret(String filename) throws IOException
      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

      public void saveSecret(Writer writer) throws IOException
      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

      private ZConfig secretConfig()