Class PemX509Certificate

java.lang.Object
java.security.cert.Certificate
java.security.cert.X509Certificate
io.netty.handler.ssl.PemX509Certificate
All Implemented Interfaces:
ByteBufHolder, PemEncoded, ReferenceCounted, java.io.Serializable, java.security.cert.X509Extension

public final class PemX509Certificate extends java.security.cert.X509Certificate implements PemEncoded
This is a special purpose implementation of a X509Certificate which allows the user to pass PEM/PKCS#8 encoded data straight into OpenSslContext without having to parse and re-encode bytes in Java land. All methods other than what's implemented in PemEncoded's throw UnsupportedOperationExceptions.
See Also:
  • Field Details

    • BEGIN_CERT

      private static final byte[] BEGIN_CERT
    • END_CERT

      private static final byte[] END_CERT
    • content

      private final ByteBuf content
  • Constructor Details

    • PemX509Certificate

      private PemX509Certificate(ByteBuf content)
  • Method Details

    • toPEM

      static PemEncoded toPEM(ByteBufAllocator allocator, boolean useDirect, java.security.cert.X509Certificate... chain) throws java.security.cert.CertificateEncodingException
      Creates a PemEncoded value from the X509Certificates.
      Throws:
      java.security.cert.CertificateEncodingException
    • append

      private static ByteBuf append(ByteBufAllocator allocator, boolean useDirect, PemEncoded encoded, int count, ByteBuf pem)
      Appends the PemEncoded value to the ByteBuf (last arg) and returns it. If the ByteBuf didn't exist yet it'll create it using the ByteBufAllocator.
    • append

      private static ByteBuf append(ByteBufAllocator allocator, boolean useDirect, java.security.cert.X509Certificate cert, int count, ByteBuf pem) throws java.security.cert.CertificateEncodingException
      Appends the X509Certificate value to the ByteBuf (last arg) and returns it. If the ByteBuf didn't exist yet it'll create it using the ByteBufAllocator.
      Throws:
      java.security.cert.CertificateEncodingException
    • newBuffer

      private static ByteBuf newBuffer(ByteBufAllocator allocator, boolean useDirect, int initialCapacity)
    • valueOf

      public static PemX509Certificate valueOf(byte[] key)
      Creates a PemX509Certificate from raw byte[]. ATTENTION: It's assumed that the given argument is a PEM/PKCS#8 encoded value. No input validation is performed to validate it.
    • valueOf

      public static PemX509Certificate valueOf(ByteBuf key)
      Creates a PemX509Certificate from raw ByteBuf. ATTENTION: It's assumed that the given argument is a PEM/PKCS#8 encoded value. No input validation is performed to validate it.
    • isSensitive

      public boolean isSensitive()
      Description copied from interface: PemEncoded
      Returns true if the PEM encoded value is considered sensitive information such as a private key.
      Specified by:
      isSensitive in interface PemEncoded
    • refCnt

      public int refCnt()
      Description copied from interface: ReferenceCounted
      Returns the reference count of this object. If 0, it means this object has been deallocated.
      Specified by:
      refCnt in interface ReferenceCounted
    • content

      public ByteBuf content()
      Description copied from interface: ByteBufHolder
      Return the data which is held by this ByteBufHolder.
      Specified by:
      content in interface ByteBufHolder
    • copy

      public PemX509Certificate copy()
      Description copied from interface: ByteBufHolder
      Creates a deep copy of this ByteBufHolder.
      Specified by:
      copy in interface ByteBufHolder
      Specified by:
      copy in interface PemEncoded
    • duplicate

      public PemX509Certificate duplicate()
      Description copied from interface: ByteBufHolder
      Duplicates this ByteBufHolder. Be aware that this will not automatically call ByteBufHolder.retain().
      Specified by:
      duplicate in interface ByteBufHolder
      Specified by:
      duplicate in interface PemEncoded
    • retainedDuplicate

      public PemX509Certificate retainedDuplicate()
      Description copied from interface: ByteBufHolder
      Duplicates this ByteBufHolder. This method returns a retained duplicate unlike ByteBufHolder.duplicate().
      Specified by:
      retainedDuplicate in interface ByteBufHolder
      Specified by:
      retainedDuplicate in interface PemEncoded
      See Also:
    • replace

      public PemX509Certificate replace(ByteBuf content)
      Description copied from interface: ByteBufHolder
      Returns a new ByteBufHolder which contains the specified content.
      Specified by:
      replace in interface ByteBufHolder
      Specified by:
      replace in interface PemEncoded
    • retain

      public PemX509Certificate retain()
      Description copied from interface: ReferenceCounted
      Increases the reference count by 1.
      Specified by:
      retain in interface ByteBufHolder
      Specified by:
      retain in interface PemEncoded
      Specified by:
      retain in interface ReferenceCounted
    • retain

      public PemX509Certificate retain(int increment)
      Description copied from interface: ReferenceCounted
      Increases the reference count by the specified increment.
      Specified by:
      retain in interface ByteBufHolder
      Specified by:
      retain in interface PemEncoded
      Specified by:
      retain in interface ReferenceCounted
    • touch

      public PemX509Certificate touch()
      Description copied from interface: ReferenceCounted
      Records the current access location of this object for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you via ResourceLeakDetector. This method is a shortcut to touch(null).
      Specified by:
      touch in interface ByteBufHolder
      Specified by:
      touch in interface PemEncoded
      Specified by:
      touch in interface ReferenceCounted
    • touch

      public PemX509Certificate touch(java.lang.Object hint)
      Description copied from interface: ReferenceCounted
      Records the current access location of this object with an additional arbitrary information for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you via ResourceLeakDetector.
      Specified by:
      touch in interface ByteBufHolder
      Specified by:
      touch in interface PemEncoded
      Specified by:
      touch in interface ReferenceCounted
    • release

      public boolean release()
      Description copied from interface: ReferenceCounted
      Decreases the reference count by 1 and deallocates this object if the reference count reaches at 0.
      Specified by:
      release in interface ReferenceCounted
      Returns:
      true if and only if the reference count became 0 and this object has been deallocated
    • release

      public boolean release(int decrement)
      Description copied from interface: ReferenceCounted
      Decreases the reference count by the specified decrement and deallocates this object if the reference count reaches at 0.
      Specified by:
      release in interface ReferenceCounted
      Returns:
      true if and only if the reference count became 0 and this object has been deallocated
    • getEncoded

      public byte[] getEncoded()
      Specified by:
      getEncoded in class java.security.cert.Certificate
    • hasUnsupportedCriticalExtension

      public boolean hasUnsupportedCriticalExtension()
      Specified by:
      hasUnsupportedCriticalExtension in interface java.security.cert.X509Extension
    • getCriticalExtensionOIDs

      public java.util.Set<java.lang.String> getCriticalExtensionOIDs()
      Specified by:
      getCriticalExtensionOIDs in interface java.security.cert.X509Extension
    • getNonCriticalExtensionOIDs

      public java.util.Set<java.lang.String> getNonCriticalExtensionOIDs()
      Specified by:
      getNonCriticalExtensionOIDs in interface java.security.cert.X509Extension
    • getExtensionValue

      public byte[] getExtensionValue(java.lang.String oid)
      Specified by:
      getExtensionValue in interface java.security.cert.X509Extension
    • checkValidity

      public void checkValidity()
      Specified by:
      checkValidity in class java.security.cert.X509Certificate
    • checkValidity

      public void checkValidity(java.util.Date date)
      Specified by:
      checkValidity in class java.security.cert.X509Certificate
    • getVersion

      public int getVersion()
      Specified by:
      getVersion in class java.security.cert.X509Certificate
    • getSerialNumber

      public java.math.BigInteger getSerialNumber()
      Specified by:
      getSerialNumber in class java.security.cert.X509Certificate
    • getIssuerDN

      public java.security.Principal getIssuerDN()
      Specified by:
      getIssuerDN in class java.security.cert.X509Certificate
    • getSubjectDN

      public java.security.Principal getSubjectDN()
      Specified by:
      getSubjectDN in class java.security.cert.X509Certificate
    • getNotBefore

      public java.util.Date getNotBefore()
      Specified by:
      getNotBefore in class java.security.cert.X509Certificate
    • getNotAfter

      public java.util.Date getNotAfter()
      Specified by:
      getNotAfter in class java.security.cert.X509Certificate
    • getTBSCertificate

      public byte[] getTBSCertificate()
      Specified by:
      getTBSCertificate in class java.security.cert.X509Certificate
    • getSignature

      public byte[] getSignature()
      Specified by:
      getSignature in class java.security.cert.X509Certificate
    • getSigAlgName

      public java.lang.String getSigAlgName()
      Specified by:
      getSigAlgName in class java.security.cert.X509Certificate
    • getSigAlgOID

      public java.lang.String getSigAlgOID()
      Specified by:
      getSigAlgOID in class java.security.cert.X509Certificate
    • getSigAlgParams

      public byte[] getSigAlgParams()
      Specified by:
      getSigAlgParams in class java.security.cert.X509Certificate
    • getIssuerUniqueID

      public boolean[] getIssuerUniqueID()
      Specified by:
      getIssuerUniqueID in class java.security.cert.X509Certificate
    • getSubjectUniqueID

      public boolean[] getSubjectUniqueID()
      Specified by:
      getSubjectUniqueID in class java.security.cert.X509Certificate
    • getKeyUsage

      public boolean[] getKeyUsage()
      Specified by:
      getKeyUsage in class java.security.cert.X509Certificate
    • getBasicConstraints

      public int getBasicConstraints()
      Specified by:
      getBasicConstraints in class java.security.cert.X509Certificate
    • verify

      public void verify(java.security.PublicKey key)
      Specified by:
      verify in class java.security.cert.Certificate
    • verify

      public void verify(java.security.PublicKey key, java.lang.String sigProvider)
      Specified by:
      verify in class java.security.cert.Certificate
    • getPublicKey

      public java.security.PublicKey getPublicKey()
      Specified by:
      getPublicKey in class java.security.cert.Certificate
    • equals

      public boolean equals(java.lang.Object o)
      Overrides:
      equals in class java.security.cert.Certificate
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.security.cert.Certificate
    • toString

      public java.lang.String toString()
      Specified by:
      toString in class java.security.cert.Certificate