Fix compile error produced by bad cherry-pick of 7ed105adbf8f2325ae8189263b6d64393e79bbf0

This commit is contained in:
Norman Maurer 2016-06-10 19:29:04 +02:00
parent 7ed105adbf
commit 9558d0b5e0
6 changed files with 12 additions and 88 deletions

View File

@ -32,8 +32,10 @@ import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509ExtendedTrustManager;
import javax.net.ssl.X509TrustManager;
import java.io.File;
import java.security.PrivateKey;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateExpiredException;
import java.security.cert.CertificateNotYetValidException;
import java.security.cert.CertificateRevokedException;
@ -541,13 +543,13 @@ public abstract class OpenSslContext extends SslContext {
ByteBuf content = pem.content();
if (content.isDirect()) {
return newBIO(content.retainedSlice());
return newBIO(content.slice().retain());
}
ByteBuf buffer = allocator.directBuffer(content.readableBytes());
try {
buffer.writeBytes(content);
return newBIO(buffer.retainedSlice());
return newBIO(buffer.slice().retain());
} finally {
try {
// If the contents of the ByteBuf is sensitive (e.g. a PrivateKey) we

View File

@ -15,7 +15,6 @@
*/
package io.netty.handler.ssl;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufHolder;
/**
@ -34,22 +33,9 @@ interface PemEncoded extends ByteBufHolder {
@Override
PemEncoded duplicate();
@Override
PemEncoded retainedDuplicate();
@Override
PemEncoded replace(ByteBuf content);
@Override
PemEncoded retain();
@Override
PemEncoded retain(int increment);
@Override
PemEncoded touch();
@Override
PemEncoded touch(Object hint);
}

View File

@ -132,34 +132,12 @@ public final class PemPrivateKey extends AbstractReferenceCounted implements Pri
@Override
public PemPrivateKey copy() {
return replace(content.copy());
return new PemPrivateKey(content.copy());
}
@Override
public PemPrivateKey duplicate() {
return replace(content.duplicate());
}
@Override
public PemPrivateKey retainedDuplicate() {
return replace(content.retainedDuplicate());
}
@Override
public PemPrivateKey replace(ByteBuf content) {
return new PemPrivateKey(content);
}
@Override
public PemPrivateKey touch() {
content.touch();
return this;
}
@Override
public PemPrivateKey touch(Object hint) {
content.touch(hint);
return this;
return new PemPrivateKey(content.duplicate());
}
@Override

View File

@ -56,33 +56,12 @@ class PemValue extends AbstractReferenceCounted implements PemEncoded {
@Override
public PemValue copy() {
return replace(content.copy());
return new PemValue(content.copy(), sensitive);
}
@Override
public PemValue duplicate() {
return replace(content.duplicate());
}
@Override
public PemValue retainedDuplicate() {
return replace(content.retainedDuplicate());
}
@Override
public PemValue replace(ByteBuf content) {
return new PemValue(content, sensitive);
}
@Override
public PemValue touch() {
return (PemValue) super.touch();
}
@Override
public PemValue touch(Object hint) {
content.touch(hint);
return this;
return new PemValue(content.duplicate(), sensitive);
}
@Override

View File

@ -208,22 +208,12 @@ public final class PemX509Certificate extends X509Certificate implements PemEnco
@Override
public PemX509Certificate copy() {
return replace(content.copy());
return new PemX509Certificate(content.copy());
}
@Override
public PemX509Certificate duplicate() {
return replace(content.duplicate());
}
@Override
public PemX509Certificate retainedDuplicate() {
return replace(content.retainedDuplicate());
}
@Override
public PemX509Certificate replace(ByteBuf content) {
return new PemX509Certificate(content);
return new PemX509Certificate(content.duplicate());
}
@Override
@ -238,18 +228,6 @@ public final class PemX509Certificate extends X509Certificate implements PemEnco
return this;
}
@Override
public PemX509Certificate touch() {
content.touch();
return this;
}
@Override
public PemX509Certificate touch(Object hint) {
content.touch(hint);
return this;
}
@Override
public boolean release() {
return content.release();

View File

@ -17,6 +17,7 @@ package io.netty.handler.ssl;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.ReadOnlyByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.base64.Base64;
import io.netty.handler.codec.base64.Base64Dialect;
@ -132,7 +133,7 @@ final class SslUtils {
* Fills the {@link ByteBuf} with zero bytes.
*/
static void zeroout(ByteBuf buffer) {
if (!buffer.isReadOnly()) {
if (!(buffer instanceof ReadOnlyByteBuf)) {
buffer.setZero(0, buffer.capacity());
}
}