fixed update openssl version
This commit is contained in:
@@ -26,6 +26,7 @@ import spock.lang.Specification
|
||||
import sun.security.x509.X509CertImpl
|
||||
|
||||
import java.security.Security
|
||||
import java.security.cert.X509Certificate
|
||||
|
||||
class TlsSetupSpec extends Specification {
|
||||
|
||||
@@ -66,8 +67,8 @@ class TlsSetupSpec extends Specification {
|
||||
!act.client
|
||||
with((OpenSslServerContext) act) {
|
||||
clientAuth == ClientAuth.NONE
|
||||
with((X509CertImpl) keyCertChain[0]) {
|
||||
getIssuerDN().name == "CN=ca.myhost.dev, OU=Blockchain CA, O=My Company"
|
||||
with((X509Certificate) keyCertChain[0]) {
|
||||
getIssuerX500Principal().name == "CN=ca.myhost.dev,OU=Blockchain CA,O=My Company"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,8 +91,8 @@ class TlsSetupSpec extends Specification {
|
||||
|
||||
with((OpenSslServerContext) act) {
|
||||
clientAuth == ClientAuth.REQUIRE
|
||||
with((X509CertImpl) keyCertChain[0]) {
|
||||
getIssuerDN().name == "CN=ca.myhost.dev, OU=Blockchain CA, O=My Company"
|
||||
with((X509Certificate) keyCertChain[0]) {
|
||||
getIssuerX500Principal().name == "CN=ca.myhost.dev,OU=Blockchain CA,O=My Company"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ class SignatureConfigReaderSpec extends Specification {
|
||||
setup:
|
||||
def config = "signed-response:\n" +
|
||||
" enabled: true\n" +
|
||||
" algorithm: SECP256K1\n" +
|
||||
" algorithm: NIST_P256\n" +
|
||||
" private-key: /root/key.pem\n"
|
||||
|
||||
when:
|
||||
@@ -26,7 +26,7 @@ class SignatureConfigReaderSpec extends Specification {
|
||||
then:
|
||||
act.enabled
|
||||
act.privateKey == "/root/key.pem"
|
||||
act.algorithm == SignatureConfig.Algorithm.SECP256K1
|
||||
act.algorithm == SignatureConfig.Algorithm.NIST_P256
|
||||
}
|
||||
|
||||
def "No path when disabled"() {
|
||||
|
||||
@@ -23,28 +23,6 @@ class EcdsaSignerSpec extends Specification {
|
||||
Security.addProvider(new BouncyCastleProvider())
|
||||
}
|
||||
|
||||
def "Reads private key"() {
|
||||
setup:
|
||||
def file = File.createTempFile("test", ".pem")
|
||||
def keygen = KeyPairGenerator.getInstance("EC")
|
||||
keygen.initialize(new ECGenParameterSpec("secp256k1"))
|
||||
def key = keygen.generateKeyPair()
|
||||
def keyBuilder = new PKCS8EncodedKeySpec(key.getPrivate().getEncoded())
|
||||
def writer = new PemWriter(new FileWriter(file.path))
|
||||
writer.writeObject(new PemObject("PRIVATE KEY", keyBuilder.getEncoded()))
|
||||
writer.close()
|
||||
|
||||
when:
|
||||
def signer = new ResponseSignerFactory(new SignatureConfig())
|
||||
def act = signer.readKey(SignatureConfig.Algorithm.SECP256K1, file.absolutePath).first
|
||||
|
||||
then:
|
||||
act == key.getPrivate()
|
||||
|
||||
cleanup:
|
||||
file.delete()
|
||||
}
|
||||
|
||||
def "Reads private key NIST P256"() {
|
||||
setup:
|
||||
def file = File.createTempFile("test", ".pem")
|
||||
@@ -84,7 +62,7 @@ class EcdsaSignerSpec extends Specification {
|
||||
def id = signer.keyId
|
||||
|
||||
then:
|
||||
id == 0xd25f1ff2c1a57235L
|
||||
id == 0xed397068b172b393L
|
||||
}
|
||||
|
||||
def "Wrap message"() {
|
||||
@@ -109,7 +87,7 @@ class EcdsaSignerSpec extends Specification {
|
||||
}
|
||||
|
||||
def keyPairGen = KeyPairGenerator.getInstance("EC")
|
||||
keyPairGen.initialize(new ECGenParameterSpec("secp256k1"))
|
||||
keyPairGen.initialize(new ECGenParameterSpec("secp256r1"))
|
||||
def pair = keyPairGen.generateKeyPair()
|
||||
def verifier = Signature.getInstance("SHA256withECDSA")
|
||||
verifier.initVerify(pair.getPublic())
|
||||
@@ -140,7 +118,7 @@ class EcdsaSignerSpec extends Specification {
|
||||
def factory = new ResponseSignerFactory(conf)
|
||||
|
||||
def sk = factory.readKey(conf.algorithm, conf.privateKey).first
|
||||
def pk = factory.extractPublicKey(KeyFactory.getInstance("EC"), sk, SignatureConfig.Algorithm.SECP256K1)
|
||||
def pk = factory.extractPublicKey(KeyFactory.getInstance("EC"), sk, SignatureConfig.Algorithm.NIST_P256)
|
||||
def verifier = Signature.getInstance("SHA256withECDSA")
|
||||
verifier.initVerify(pk)
|
||||
verifier.update("DSHACKLESIG/10/infura/${Hex.encodeHexString(sha256.digest(result))}".getBytes())
|
||||
|
||||
Reference in New Issue
Block a user