parent
2ac69160c7
commit
7bd9989614
|
@ -20,7 +20,6 @@ import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.PrivateKey;
|
import java.security.PrivateKey;
|
||||||
import java.security.interfaces.ECPrivateKey;
|
import java.security.interfaces.ECPrivateKey;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
@ -218,16 +217,9 @@ class PemPrivateKeyParserTests {
|
||||||
// openssl pkcs8 -topk8 -in <input file> -out <output file> -v2 <algorithm>
|
// openssl pkcs8 -topk8 -in <input file> -out <output file> -v2 <algorithm>
|
||||||
// -passout pass:test
|
// -passout pass:test
|
||||||
// where <algorithm> is aes128 or aes256
|
// where <algorithm> is aes128 or aes256
|
||||||
<<<<<<< HEAD
|
|
||||||
String content = read("org/springframework/boot/web/server/pkcs8/" + file);
|
|
||||||
List<PrivateKey> privateKeys = PemPrivateKeyParser.parse(content, "test");
|
|
||||||
assertThat(privateKeys).isNotEmpty();
|
|
||||||
PrivateKey privateKey = privateKeys.get(0);
|
|
||||||
=======
|
|
||||||
PrivateKey privateKey = PemPrivateKeyParser.parse(read("org/springframework/boot/web/server/pkcs8/" + file),
|
PrivateKey privateKey = PemPrivateKeyParser.parse(read("org/springframework/boot/web/server/pkcs8/" + file),
|
||||||
"test");
|
"test");
|
||||||
assertThat(privateKey).isNotNull();
|
assertThat(privateKey).isNotNull();
|
||||||
>>>>>>> parent of 32e6ce210e1 (Allow PemPrivateKeyParser to parse multiple keys)
|
|
||||||
assertThat(privateKey.getFormat()).isEqualTo("PKCS#8");
|
assertThat(privateKey.getFormat()).isEqualTo("PKCS#8");
|
||||||
assertThat(privateKey.getAlgorithm()).isEqualTo(algorithm);
|
assertThat(privateKey.getAlgorithm()).isEqualTo(algorithm);
|
||||||
}
|
}
|
||||||
|
@ -267,24 +259,13 @@ class PemPrivateKeyParserTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldNotParseEncryptedPkcs1() throws Exception {
|
void shouldNotParseEncryptedPkcs1() {
|
||||||
// created with:
|
// created with:
|
||||||
// openssl genrsa -aes-256-cbc -out rsa-aes-256-cbc.key
|
// openssl genrsa -aes-256-cbc -out rsa-aes-256-cbc.key
|
||||||
<<<<<<< HEAD
|
|
||||||
assertThat(PemPrivateKeyParser.parse(read("org/springframework/boot/web/server/pkcs1/rsa-aes-256-cbc.key"),
|
|
||||||
"test"))
|
|
||||||
.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
private PrivateKey parse(String key) {
|
|
||||||
List<PrivateKey> keys = PemPrivateKeyParser.parse(key);
|
|
||||||
return (!ObjectUtils.isEmpty(keys)) ? keys.get(0) : null;
|
|
||||||
=======
|
|
||||||
assertThatIllegalStateException()
|
assertThatIllegalStateException()
|
||||||
.isThrownBy(() -> PemPrivateKeyParser
|
.isThrownBy(() -> PemPrivateKeyParser
|
||||||
.parse(read("org/springframework/boot/web/server/pkcs1/rsa-aes-256-cbc.key"), "test"))
|
.parse(read("org/springframework/boot/web/server/pkcs1/rsa-aes-256-cbc.key"), "test"))
|
||||||
.withMessageContaining("Unrecognized private key format");
|
.withMessageContaining("Unrecognized private key format");
|
||||||
>>>>>>> parent of 32e6ce210e1 (Allow PemPrivateKeyParser to parse multiple keys)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String read(String path) throws IOException {
|
private String read(String path) throws IOException {
|
||||||
|
|
Loading…
Reference in New Issue