mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8245679: KeyStore cannot probe PKCS12 keystore if BouncyCastle is the top security provider
Reviewed-by: mullan
This commit is contained in:
parent
241f401815
commit
2536cbf2cf
3 changed files with 134 additions and 44 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -75,6 +75,22 @@ public abstract class JavaKeyStore extends KeyStoreSpi {
|
|||
public DualFormatJKS() {
|
||||
super("JKS", JKS.class, "PKCS12", PKCS12KeyStore.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Probe the first few bytes of the keystore data stream for a valid
|
||||
* JKS keystore encoding.
|
||||
*/
|
||||
@Override
|
||||
public boolean engineProbe(InputStream stream) throws IOException {
|
||||
DataInputStream dataStream;
|
||||
if (stream instanceof DataInputStream) {
|
||||
dataStream = (DataInputStream)stream;
|
||||
} else {
|
||||
dataStream = new DataInputStream(stream);
|
||||
}
|
||||
|
||||
return MAGIC == dataStream.readInt();
|
||||
}
|
||||
}
|
||||
|
||||
private static final Debug debug = Debug.getInstance("keystore");
|
||||
|
@ -828,20 +844,4 @@ public abstract class JavaKeyStore extends KeyStoreSpi {
|
|||
}
|
||||
return passwdBytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Probe the first few bytes of the keystore data stream for a valid
|
||||
* JKS keystore encoding.
|
||||
*/
|
||||
@Override
|
||||
public boolean engineProbe(InputStream stream) throws IOException {
|
||||
DataInputStream dataStream;
|
||||
if (stream instanceof DataInputStream) {
|
||||
dataStream = (DataInputStream)stream;
|
||||
} else {
|
||||
dataStream = new DataInputStream(stream);
|
||||
}
|
||||
|
||||
return MAGIC == dataStream.readInt();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue