PemX509Certificate Class — netty Architecture
Architecture documentation for the PemX509Certificate class in PemX509Certificate.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 5a07f07f_f60b_c2b9_81ac_c030312abb06["PemX509Certificate"] 686f052e_f9b3_6324_58d6_917732df1127["PemX509Certificate.java"] 5a07f07f_f60b_c2b9_81ac_c030312abb06 -->|defined in| 686f052e_f9b3_6324_58d6_917732df1127 78a8783e_da81_c930_635c_adf8144956d4["PemEncoded()"] 5a07f07f_f60b_c2b9_81ac_c030312abb06 -->|method| 78a8783e_da81_c930_635c_adf8144956d4 431f65dc_c26a_2796_bbd4_afee52eaf0ea["ByteBuf()"] 5a07f07f_f60b_c2b9_81ac_c030312abb06 -->|method| 431f65dc_c26a_2796_bbd4_afee52eaf0ea e8ddac2b_7572_44f3_8292_92f3d6fcca28["PemX509Certificate()"] 5a07f07f_f60b_c2b9_81ac_c030312abb06 -->|method| e8ddac2b_7572_44f3_8292_92f3d6fcca28 79b80c9a_5b3c_8de1_9d75_94c54e1a74d4["isSensitive()"] 5a07f07f_f60b_c2b9_81ac_c030312abb06 -->|method| 79b80c9a_5b3c_8de1_9d75_94c54e1a74d4 2d60c04e_4129_888f_be02_a51f49a5f656["refCnt()"] 5a07f07f_f60b_c2b9_81ac_c030312abb06 -->|method| 2d60c04e_4129_888f_be02_a51f49a5f656 813828f8_5915_680b_1d84_589e2ea1dcb6["release()"] 5a07f07f_f60b_c2b9_81ac_c030312abb06 -->|method| 813828f8_5915_680b_1d84_589e2ea1dcb6 9732cd5f_6ac8_16d2_d132_70dc632fb717["getEncoded()"] 5a07f07f_f60b_c2b9_81ac_c030312abb06 -->|method| 9732cd5f_6ac8_16d2_d132_70dc632fb717 ef207d41_194d_3b4c_3389_79bdab979544["hasUnsupportedCriticalExtension()"] 5a07f07f_f60b_c2b9_81ac_c030312abb06 -->|method| ef207d41_194d_3b4c_3389_79bdab979544 6e7a9197_c0b4_3e11_d38f_8b1c3c4d5b33["getCriticalExtensionOIDs()"] 5a07f07f_f60b_c2b9_81ac_c030312abb06 -->|method| 6e7a9197_c0b4_3e11_d38f_8b1c3c4d5b33 bb52a3a0_6fcd_8da6_eaf7_f3d3eca7b7ab["getNonCriticalExtensionOIDs()"] 5a07f07f_f60b_c2b9_81ac_c030312abb06 -->|method| bb52a3a0_6fcd_8da6_eaf7_f3d3eca7b7ab 291d05d0_cd90_dfb6_e7e7_cf1117657b70["getExtensionValue()"] 5a07f07f_f60b_c2b9_81ac_c030312abb06 -->|method| 291d05d0_cd90_dfb6_e7e7_cf1117657b70 963c966a_082f_30d0_364b_dfffc8a663fc["checkValidity()"] 5a07f07f_f60b_c2b9_81ac_c030312abb06 -->|method| 963c966a_082f_30d0_364b_dfffc8a663fc f5758e05_07e4_3e17_6fb3_9b953f5b3491["getVersion()"] 5a07f07f_f60b_c2b9_81ac_c030312abb06 -->|method| f5758e05_07e4_3e17_6fb3_9b953f5b3491
Relationship Graph
Source Code
handler/src/main/java/io/netty/handler/ssl/PemX509Certificate.java lines 49–403
public final class PemX509Certificate extends X509Certificate implements PemEncoded {
private static final byte[] BEGIN_CERT = "-----BEGIN CERTIFICATE-----\n".getBytes(CharsetUtil.US_ASCII);
private static final byte[] END_CERT = "\n-----END CERTIFICATE-----\n".getBytes(CharsetUtil.US_ASCII);
/**
* Creates a {@link PemEncoded} value from the {@link X509Certificate}s.
*/
static PemEncoded toPEM(ByteBufAllocator allocator, boolean useDirect,
X509Certificate... chain) throws CertificateEncodingException {
checkNonEmpty(chain, "chain");
// We can take a shortcut if there is only one certificate and
// it already happens to be a PemEncoded instance. This is the
// ideal case and reason why all this exists. It allows the user
// to pass pre-encoded bytes straight into OpenSSL without having
// to do any of the extra work.
if (chain.length == 1) {
X509Certificate first = chain[0];
if (first instanceof PemEncoded) {
return ((PemEncoded) first).retain();
}
}
boolean success = false;
ByteBuf pem = null;
try {
for (X509Certificate cert : chain) {
if (cert == null) {
throw new IllegalArgumentException("Null element in chain: " + Arrays.toString(chain));
}
if (cert instanceof PemEncoded) {
pem = append(allocator, useDirect, (PemEncoded) cert, chain.length, pem);
} else {
pem = append(allocator, useDirect, cert, chain.length, pem);
}
}
PemValue value = new PemValue(pem, false);
success = true;
return value;
} finally {
// Make sure we never leak the PEM's ByteBuf in the event of an Exception
if (!success && pem != null) {
pem.release();
}
}
}
/**
* Appends the {@link PemEncoded} value to the {@link ByteBuf} (last arg) and returns it.
* If the {@link ByteBuf} didn't exist yet it'll create it using the {@link ByteBufAllocator}.
*/
private static ByteBuf append(ByteBufAllocator allocator, boolean useDirect,
PemEncoded encoded, int count, ByteBuf pem) {
ByteBuf content = encoded.content();
if (pem == null) {
// see the other append() method
pem = newBuffer(allocator, useDirect, content.readableBytes() * count);
}
pem.writeBytes(content.slice());
return pem;
}
/**
* Appends the {@link X509Certificate} value to the {@link ByteBuf} (last arg) and returns it.
* If the {@link ByteBuf} didn't exist yet it'll create it using the {@link ByteBufAllocator}.
*/
private static ByteBuf append(ByteBufAllocator allocator, boolean useDirect,
X509Certificate cert, int count, ByteBuf pem) throws CertificateEncodingException {
ByteBuf encoded = Unpooled.wrappedBuffer(cert.getEncoded());
try {
ByteBuf base64 = SslUtils.toBase64(allocator, encoded);
try {
Source
Frequently Asked Questions
What is the PemX509Certificate class?
PemX509Certificate is a class in the netty codebase, defined in handler/src/main/java/io/netty/handler/ssl/PemX509Certificate.java.
Where is PemX509Certificate defined?
PemX509Certificate is defined in handler/src/main/java/io/netty/handler/ssl/PemX509Certificate.java at line 49.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free