Package io.netty.handler.ssl
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
UnsupportedOperationException
s.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.security.cert.Certificate
Certificate.CertificateRep
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final byte[]
private final ByteBuf
private static final byte[]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static ByteBuf
append
(ByteBufAllocator allocator, boolean useDirect, PemEncoded encoded, int count, ByteBuf pem) Appends thePemEncoded
value to theByteBuf
(last arg) and returns it.private static ByteBuf
append
(ByteBufAllocator allocator, boolean useDirect, X509Certificate cert, int count, ByteBuf pem) Appends theX509Certificate
value to theByteBuf
(last arg) and returns it.void
void
checkValidity
(Date date) content()
Return the data which is held by thisByteBufHolder
.copy()
Creates a deep copy of thisByteBufHolder
.Duplicates thisByteBufHolder
.boolean
int
byte[]
byte[]
getExtensionValue
(String oid) boolean[]
boolean[]
byte[]
byte[]
boolean[]
byte[]
int
int
hashCode()
boolean
boolean
Returnstrue
if the PEM encoded value is considered sensitive information such as a private key.private static ByteBuf
newBuffer
(ByteBufAllocator allocator, boolean useDirect, int initialCapacity) int
refCnt()
Returns the reference count of this object.boolean
release()
Decreases the reference count by1
and deallocates this object if the reference count reaches at0
.boolean
release
(int decrement) Decreases the reference count by the specifieddecrement
and deallocates this object if the reference count reaches at0
.Returns a newByteBufHolder
which contains the specifiedcontent
.retain()
Increases the reference count by1
.retain
(int increment) Increases the reference count by the specifiedincrement
.Duplicates thisByteBufHolder
.(package private) static PemEncoded
toPEM
(ByteBufAllocator allocator, boolean useDirect, X509Certificate... chain) Creates aPemEncoded
value from theX509Certificate
s.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 PemX509Certificate
valueOf
(byte[] key) Creates aPemX509Certificate
from rawbyte[]
.static PemX509Certificate
Creates aPemX509Certificate
from rawByteBuf
.void
void
Methods inherited from class java.security.cert.X509Certificate
getExtendedKeyUsage, getIssuerAlternativeNames, getIssuerX500Principal, getSubjectAlternativeNames, getSubjectX500Principal, verify
Methods inherited from class java.security.cert.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 aPemEncoded
value from theX509Certificate
s.- Throws:
CertificateEncodingException
-
append
private static ByteBuf append(ByteBufAllocator allocator, boolean useDirect, PemEncoded encoded, int count, ByteBuf pem) Appends thePemEncoded
value to theByteBuf
(last arg) and returns it. If theByteBuf
didn'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 theX509Certificate
value to theByteBuf
(last arg) and returns it. If theByteBuf
didn't exist yet it'll create it using theByteBufAllocator
.- Throws:
CertificateEncodingException
-
newBuffer
private static ByteBuf newBuffer(ByteBufAllocator allocator, boolean useDirect, int initialCapacity) -
valueOf
Creates aPemX509Certificate
from 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 aPemX509Certificate
from 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:PemEncoded
Returnstrue
if the PEM encoded value is considered sensitive information such as a private key.- Specified by:
isSensitive
in interfacePemEncoded
-
refCnt
public int refCnt()Description copied from interface:ReferenceCounted
Returns the reference count of this object. If0
, it means this object has been deallocated.- Specified by:
refCnt
in interfaceReferenceCounted
-
content
Description copied from interface:ByteBufHolder
Return the data which is held by thisByteBufHolder
.- Specified by:
content
in interfaceByteBufHolder
-
copy
Description copied from interface:ByteBufHolder
Creates a deep copy of thisByteBufHolder
.- Specified by:
copy
in interfaceByteBufHolder
- Specified by:
copy
in interfacePemEncoded
-
duplicate
Description copied from interface:ByteBufHolder
Duplicates thisByteBufHolder
. Be aware that this will not automatically callByteBufHolder.retain()
.- Specified by:
duplicate
in interfaceByteBufHolder
- Specified by:
duplicate
in interfacePemEncoded
-
retainedDuplicate
Description copied from interface:ByteBufHolder
Duplicates thisByteBufHolder
. This method returns a retained duplicate unlikeByteBufHolder.duplicate()
.- Specified by:
retainedDuplicate
in interfaceByteBufHolder
- Specified by:
retainedDuplicate
in interfacePemEncoded
- See Also:
-
replace
Description copied from interface:ByteBufHolder
Returns a newByteBufHolder
which contains the specifiedcontent
.- Specified by:
replace
in interfaceByteBufHolder
- Specified by:
replace
in interfacePemEncoded
-
retain
Description copied from interface:ReferenceCounted
Increases the reference count by1
.- Specified by:
retain
in interfaceByteBufHolder
- Specified by:
retain
in interfacePemEncoded
- Specified by:
retain
in interfaceReferenceCounted
-
retain
Description copied from interface:ReferenceCounted
Increases the reference count by the specifiedincrement
.- Specified by:
retain
in interfaceByteBufHolder
- Specified by:
retain
in interfacePemEncoded
- Specified by:
retain
in interfaceReferenceCounted
-
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 viaResourceLeakDetector
. This method is a shortcut totouch(null)
.- Specified by:
touch
in interfaceByteBufHolder
- Specified by:
touch
in interfacePemEncoded
- Specified by:
touch
in interfaceReferenceCounted
-
touch
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 viaResourceLeakDetector
.- Specified by:
touch
in interfaceByteBufHolder
- Specified by:
touch
in interfacePemEncoded
- Specified by:
touch
in interfaceReferenceCounted
-
release
public boolean release()Description copied from interface:ReferenceCounted
Decreases the reference count by1
and deallocates this object if the reference count reaches at0
.- Specified by:
release
in interfaceReferenceCounted
- Returns:
true
if and only if the reference count became0
and this object has been deallocated
-
release
public boolean release(int decrement) Description copied from interface:ReferenceCounted
Decreases the reference count by the specifieddecrement
and deallocates this object if the reference count reaches at0
.- Specified by:
release
in interfaceReferenceCounted
- Returns:
true
if and only if the reference count became0
and this object has been deallocated
-
getEncoded
public byte[] getEncoded()- Specified by:
getEncoded
in classCertificate
-
hasUnsupportedCriticalExtension
public boolean hasUnsupportedCriticalExtension()- Specified by:
hasUnsupportedCriticalExtension
in interfaceX509Extension
-
getCriticalExtensionOIDs
- Specified by:
getCriticalExtensionOIDs
in interfaceX509Extension
-
getNonCriticalExtensionOIDs
- Specified by:
getNonCriticalExtensionOIDs
in interfaceX509Extension
-
getExtensionValue
- Specified by:
getExtensionValue
in interfaceX509Extension
-
checkValidity
public void checkValidity()- Specified by:
checkValidity
in classX509Certificate
-
checkValidity
- Specified by:
checkValidity
in classX509Certificate
-
getVersion
public int getVersion()- Specified by:
getVersion
in classX509Certificate
-
getSerialNumber
- Specified by:
getSerialNumber
in classX509Certificate
-
getIssuerDN
- Specified by:
getIssuerDN
in classX509Certificate
-
getSubjectDN
- Specified by:
getSubjectDN
in classX509Certificate
-
getNotBefore
- Specified by:
getNotBefore
in classX509Certificate
-
getNotAfter
- Specified by:
getNotAfter
in classX509Certificate
-
getTBSCertificate
public byte[] getTBSCertificate()- Specified by:
getTBSCertificate
in classX509Certificate
-
getSignature
public byte[] getSignature()- Specified by:
getSignature
in classX509Certificate
-
getSigAlgName
- Specified by:
getSigAlgName
in classX509Certificate
-
getSigAlgOID
- Specified by:
getSigAlgOID
in classX509Certificate
-
getSigAlgParams
public byte[] getSigAlgParams()- Specified by:
getSigAlgParams
in classX509Certificate
-
getIssuerUniqueID
public boolean[] getIssuerUniqueID()- Specified by:
getIssuerUniqueID
in classX509Certificate
-
getSubjectUniqueID
public boolean[] getSubjectUniqueID()- Specified by:
getSubjectUniqueID
in classX509Certificate
-
getKeyUsage
public boolean[] getKeyUsage()- Specified by:
getKeyUsage
in classX509Certificate
-
getBasicConstraints
public int getBasicConstraints()- Specified by:
getBasicConstraints
in classX509Certificate
-
verify
- Specified by:
verify
in classCertificate
-
verify
- Specified by:
verify
in classCertificate
-
getPublicKey
- Specified by:
getPublicKey
in classCertificate
-
equals
- Overrides:
equals
in classCertificate
-
hashCode
public int hashCode()- Overrides:
hashCode
in classCertificate
-
toString
- Specified by:
toString
in classCertificate
-