Class PemX509Certificate
java.lang.Object
java.security.cert.Certificate
java.security.cert.X509Certificate
io.netty.handler.ssl.PemX509Certificate
- All Implemented Interfaces:
ByteBufHolder, PemEncoded, ReferenceCounted, Serializable, X509Extension
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class Certificate
Certificate.CertificateRep -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final byte[]private final ByteBufprivate static final byte[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static ByteBufappend(ByteBufAllocator allocator, boolean useDirect, PemEncoded encoded, int count, ByteBuf pem) Appends thePemEncodedvalue to theByteBuf(last arg) and returns it.private static ByteBufappend(ByteBufAllocator allocator, boolean useDirect, X509Certificate cert, int count, ByteBuf pem) Appends theX509Certificatevalue to theByteBuf(last arg) and returns it.voidvoidcheckValidity(Date date) content()Return the data which is held by thisByteBufHolder.copy()Creates a deep copy of thisByteBufHolder.Duplicates thisByteBufHolder.booleanintbyte[]byte[]getExtensionValue(String oid) boolean[]boolean[]byte[]byte[]boolean[]byte[]intinthashCode()booleanbooleanReturnstrueif the PEM encoded value is considered sensitive information such as a private key.private static ByteBufnewBuffer(ByteBufAllocator allocator, boolean useDirect, int initialCapacity) intrefCnt()Returns the reference count of this object.booleanrelease()Decreases the reference count by1and deallocates this object if the reference count reaches at0.booleanrelease(int decrement) Decreases the reference count by the specifieddecrementand deallocates this object if the reference count reaches at0.Returns a newByteBufHolderwhich contains the specifiedcontent.retain()Increases the reference count by1.retain(int increment) Increases the reference count by the specifiedincrement.Duplicates thisByteBufHolder.(package private) static PemEncodedtoPEM(ByteBufAllocator allocator, boolean useDirect, X509Certificate... chain) Creates aPemEncodedvalue from theX509Certificates.toString()touch()Records the current access location of this object for debugging purposes.Records the current access location of this object with an additional arbitrary information for debugging purposes.static PemX509CertificatevalueOf(byte[] key) Creates aPemX509Certificatefrom rawbyte[].static PemX509CertificateCreates aPemX509Certificatefrom rawByteBuf.voidvoidMethods inherited from class X509Certificate
getExtendedKeyUsage, getIssuerAlternativeNames, getIssuerX500Principal, getSubjectAlternativeNames, getSubjectX500Principal, verifyMethods inherited from class Certificate
getType, writeReplace
-
Field Details
-
BEGIN_CERT
private static final byte[] BEGIN_CERT -
END_CERT
private static final byte[] END_CERT -
-
-
Constructor Details
-
PemX509Certificate
-
-
Method Details
-
toPEM
static PemEncoded toPEM(ByteBufAllocator allocator, boolean useDirect, X509Certificate... chain) throws CertificateEncodingException Creates aPemEncodedvalue from theX509Certificates.- Throws:
CertificateEncodingException
-
append
private static ByteBuf append(ByteBufAllocator allocator, boolean useDirect, PemEncoded encoded, int count, ByteBuf pem) Appends thePemEncodedvalue to theByteBuf(last arg) and returns it. If theByteBufdidn't exist yet it'll create it using theByteBufAllocator. -
append
private static ByteBuf append(ByteBufAllocator allocator, boolean useDirect, X509Certificate cert, int count, ByteBuf pem) throws CertificateEncodingException Appends theX509Certificatevalue to theByteBuf(last arg) and returns it. If theByteBufdidn't exist yet it'll create it using theByteBufAllocator.- Throws:
CertificateEncodingException
-
newBuffer
private static ByteBuf newBuffer(ByteBufAllocator allocator, boolean useDirect, int initialCapacity) -
valueOf
Creates aPemX509Certificatefrom rawbyte[]. ATTENTION: It's assumed that the given argument is a PEM/PKCS#8 encoded value. No input validation is performed to validate it. -
valueOf
Creates aPemX509Certificatefrom rawByteBuf. 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:PemEncodedReturnstrueif the PEM encoded value is considered sensitive information such as a private key.- Specified by:
isSensitivein interfacePemEncoded
-
refCnt
public int refCnt()Description copied from interface:ReferenceCountedReturns the reference count of this object. If0, it means this object has been deallocated.- Specified by:
refCntin interfaceReferenceCounted
-
content
Description copied from interface:ByteBufHolderReturn the data which is held by thisByteBufHolder.- Specified by:
contentin interfaceByteBufHolder
-
copy
Description copied from interface:ByteBufHolderCreates a deep copy of thisByteBufHolder.- Specified by:
copyin interfaceByteBufHolder- Specified by:
copyin interfacePemEncoded
-
duplicate
Description copied from interface:ByteBufHolderDuplicates thisByteBufHolder. Be aware that this will not automatically callByteBufHolder.retain().- Specified by:
duplicatein interfaceByteBufHolder- Specified by:
duplicatein interfacePemEncoded
-
retainedDuplicate
Description copied from interface:ByteBufHolderDuplicates thisByteBufHolder. This method returns a retained duplicate unlikeByteBufHolder.duplicate().- Specified by:
retainedDuplicatein interfaceByteBufHolder- Specified by:
retainedDuplicatein interfacePemEncoded- See Also:
-
replace
Description copied from interface:ByteBufHolderReturns a newByteBufHolderwhich contains the specifiedcontent.- Specified by:
replacein interfaceByteBufHolder- Specified by:
replacein interfacePemEncoded
-
retain
Description copied from interface:ReferenceCountedIncreases the reference count by1.- Specified by:
retainin interfaceByteBufHolder- Specified by:
retainin interfacePemEncoded- Specified by:
retainin interfaceReferenceCounted
-
retain
Description copied from interface:ReferenceCountedIncreases the reference count by the specifiedincrement.- Specified by:
retainin interfaceByteBufHolder- Specified by:
retainin interfacePemEncoded- Specified by:
retainin interfaceReferenceCounted
-
touch
Description copied from interface:ReferenceCountedRecords 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 viaResourceLeakDetector. This method is a shortcut totouch(null).- Specified by:
touchin interfaceByteBufHolder- Specified by:
touchin interfacePemEncoded- Specified by:
touchin interfaceReferenceCounted
-
touch
Description copied from interface:ReferenceCountedRecords 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 viaResourceLeakDetector.- Specified by:
touchin interfaceByteBufHolder- Specified by:
touchin interfacePemEncoded- Specified by:
touchin interfaceReferenceCounted
-
release
public boolean release()Description copied from interface:ReferenceCountedDecreases the reference count by1and deallocates this object if the reference count reaches at0.- Specified by:
releasein interfaceReferenceCounted- Returns:
trueif and only if the reference count became0and this object has been deallocated
-
release
public boolean release(int decrement) Description copied from interface:ReferenceCountedDecreases the reference count by the specifieddecrementand deallocates this object if the reference count reaches at0.- Specified by:
releasein interfaceReferenceCounted- Returns:
trueif and only if the reference count became0and this object has been deallocated
-
getEncoded
public byte[] getEncoded()- Specified by:
getEncodedin classCertificate
-
hasUnsupportedCriticalExtension
public boolean hasUnsupportedCriticalExtension()- Specified by:
hasUnsupportedCriticalExtensionin interfaceX509Extension
-
getCriticalExtensionOIDs
- Specified by:
getCriticalExtensionOIDsin interfaceX509Extension
-
getNonCriticalExtensionOIDs
- Specified by:
getNonCriticalExtensionOIDsin interfaceX509Extension
-
getExtensionValue
- Specified by:
getExtensionValuein interfaceX509Extension
-
checkValidity
public void checkValidity()- Specified by:
checkValidityin classX509Certificate
-
checkValidity
- Specified by:
checkValidityin classX509Certificate
-
getVersion
public int getVersion()- Specified by:
getVersionin classX509Certificate
-
getSerialNumber
- Specified by:
getSerialNumberin classX509Certificate
-
getIssuerDN
- Specified by:
getIssuerDNin classX509Certificate
-
getSubjectDN
- Specified by:
getSubjectDNin classX509Certificate
-
getNotBefore
- Specified by:
getNotBeforein classX509Certificate
-
getNotAfter
- Specified by:
getNotAfterin classX509Certificate
-
getTBSCertificate
public byte[] getTBSCertificate()- Specified by:
getTBSCertificatein classX509Certificate
-
getSignature
public byte[] getSignature()- Specified by:
getSignaturein classX509Certificate
-
getSigAlgName
- Specified by:
getSigAlgNamein classX509Certificate
-
getSigAlgOID
- Specified by:
getSigAlgOIDin classX509Certificate
-
getSigAlgParams
public byte[] getSigAlgParams()- Specified by:
getSigAlgParamsin classX509Certificate
-
getIssuerUniqueID
public boolean[] getIssuerUniqueID()- Specified by:
getIssuerUniqueIDin classX509Certificate
-
getSubjectUniqueID
public boolean[] getSubjectUniqueID()- Specified by:
getSubjectUniqueIDin classX509Certificate
-
getKeyUsage
public boolean[] getKeyUsage()- Specified by:
getKeyUsagein classX509Certificate
-
getBasicConstraints
public int getBasicConstraints()- Specified by:
getBasicConstraintsin classX509Certificate
-
verify
- Specified by:
verifyin classCertificate
-
verify
- Specified by:
verifyin classCertificate
-
getPublicKey
- Specified by:
getPublicKeyin classCertificate
-
equals
- Overrides:
equalsin classCertificate
-
hashCode
public int hashCode()- Overrides:
hashCodein classCertificate
-
toString
- Specified by:
toStringin classCertificate
-