Hi team,
I’m working on http signatures, based on this development: https://github.com/apigee/iloveapis2015-hmac-httpsignature/tree/master/httpsig/callout
Now, no matter what I’m doing, I always get this error:
{
"error": "the signature is malformed ()"
}
I’m using simple proxy flow, that contains:
- PreFlow:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<JavaCallout name="Java-ParseHttpSignature">
<Properties/>
<ClassName>com.google.apigee.callout.httpsignature.SignatureParserCallout</ClassName>
<ResourceURL>java://edge-custom-httpsig-1.0.2.jar</ResourceURL>
</JavaCallout>
This will take the Signature header and parse it, which it does well.
- I have some proxy path, like /rsa-t2, and there I have two policies:
a. Pulls out my public key from KVM:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<KeyValueMapOperations async="false" continueOnError="false" enabled="true" name="getkey" mapIdentifier="keys">
<DisplayName>getkey</DisplayName>
<Properties/>
<ExclusiveCache>false</ExclusiveCache>
<ExpiryTimeInSecs>300</ExpiryTimeInSecs>
<Get assignTo="pkey">
<Key>
<Parameter>signer</Parameter>
</Key>
</Get>
<Scope>environment</Scope>
</KeyValueMapOperations>
.. and this is the key (key from example folder ~ key2-public.pem:
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA9htfJRKA3EEbvmvrqKON
CGSDHYH3bJffNeca1sqvSN8uA2r16qabG5n21kvOZuzYr6gsK1Qpi870vELbir00
xybyXTJKDjXsSTO+hSVa+bmr8V+ncAJr8ZkyWjPDYufGAsXqbLbUVWAbtiyCbgdA
YBktWwXthQdz867l1ow21ZgR+vwzSDAAg8rK6PGIxqZ+7iVIUMW9eGJpr5vSdRXX
Oushgcr84EBs7TH+0Pzw+rV2PRjD9gpyFvX/JMzx3UaJNscPEdne9wtuolk6VJpS
KPTKTaXinS0grYvSUeY8+qmli20btNiaJ2La+giYAuPMiL99iStmlj+pTgnuVY65
JQIDAQAB
-----END PUBLIC KEY-----
b. JavaCallout for signature parsing:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<JavaCallout name="Java-VerifyHttpSignature1">
<Properties>
<Property name="algorithm">rsa-sha256</Property>
<Property name="public-key">{pkey}</Property>
</Properties>
<ClassName>com.google.apigee.callout.httpsignature.SignatureVerifierCallout</ClassName>
<ResourceURL>java://edge-custom-httpsig-1.0.2.jar</ResourceURL>
</JavaCallout>
Now, at this level I expect that my signature will be valid.
I’m singing the content with online signature service (if needed, I can provide link)
I’m singing the content with corresponding privatekey from example folder: key2-private.pem:
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA9htfJRKA3EEbvmvrqKONCGSDHYH3bJffNeca1sqvSN8uA2r1
6qabG5n21kvOZuzYr6gsK1Qpi870vELbir00xybyXTJKDjXsSTO+hSVa+bmr8V+n
cAJr8ZkyWjPDYufGAsXqbLbUVWAbtiyCbgdAYBktWwXthQdz867l1ow21ZgR+vwz
SDAAg8rK6PGIxqZ+7iVIUMW9eGJpr5vSdRXXOushgcr84EBs7TH+0Pzw+rV2PRjD
9gpyFvX/JMzx3UaJNscPEdne9wtuolk6VJpSKPTKTaXinS0grYvSUeY8+qmli20b
tNiaJ2La+giYAuPMiL99iStmlj+pTgnuVY65JQIDAQABAoIBAFVRp+pyP7ob2EJr
p4cPLBV8wve31s8O15MYS3WrTpk0xf7pVdfDaoJnHeus3CFSesxqwOVEiCKv3Khn
hTTT4zgniF5G0OWcTA4UojgGe0OX2sQTJTjvnfxj39DloRbowvyzIFIQEAyJBRJi
29TJLsgh8ldb9rvnmYshVwzKDzh8ka92uv2y4Ggnc2yCGXAS1nCANUv6zB/SRoq0
hID7rbLMIO4oC6SqThWZ9IrLFcyiJR1Exs8/Wsjib7CKMtSnFJwBGiz0QVm5ZG0G
zYaF5rl0kHEfO/nqoa5GWUaaWBuRqxYUgKuzTaifqH4ieRXK7vC+80Y5/fAPQ7oq
dvTXGAECgYEA/0rC3ZH4wbWnHbynsxjo/NWjBi7iJUxaLMndeSy9q0sR2y2kZfiE
/qDxRevM+gfLNx3i3LI6g2/gkDbQ6BvnopxihRf3kAIAG2KeAjH3+cA+cuHC2KrO
9kh12zePoDSaZbeIMllIwDFOpHJEOlGSSzTA17ngrj4KgIX85CcKYW0CgYEA9soW
9qdGxVnzDNuj6JVxt2vnguV+XXX3OD5/cHoZoPT3VvqhQDoNyeHLyREuJ7fflxsi
BsTTEHPqP9eyzkZ8uSMphGjGYkUmBxkGRyD5F4POv49n8GyGPN0QHHSeYQinVQN+
QVU1EHPD+Z64NKzyQ1whk7kl5U0980/Sy8/kG5kCgYEA+Qk6HKC39Gc61cRiJ1Dm
fzX8aRy1GMNpuAVX2kwt3fpGOfRFSf/r5OSlWJsVAtc1gtfRpY7ri6pIewYuNi56
gONjLAhcRIvfBNfn4aZTC7xgbvsScv/1EsVOywFhR1vpPc6SuuLkGDBBUiPxsJ5A
QsL8V7UIm5ED96o9L2dyNeUCgYEA68dVux9DsQbn+8/YQDyPIXN5Awjo+rfakqS7
MqWk2K9Ro4reBjOwusD75kSAuTel6YLltlvTXrOwCIC2dvbG8EZUwwkrB/YSh9Nz
uP8anEm0fDWxUvUMJxf47YbJTeFrpQAqXpbelLJVeKYYTVMyPgLGnZDVUMbEOjJ4
LXqX73kCgYBRHMHQ6RXyTMvPy58dbicCiXIDIN7Zf1eB4qONuhJTXT6m1fOyUAQF
LauLv1+9rBA8Cy2aBvOW5FyJ1jFJ9qG43JYc7i6O1NdlM/hUAcAm/8v6Gsgd6w7Q
+v1Nz0cBMYJA4cqLFzuYE3bGIDeyTAxULt/V6CIL2w9LKcmFeQ0O0Q==
-----END RSA PRIVATE KEY-----
…and this is my signed header
user: denis
Now, to wrap all up:
- sending get request to my endpoint with headers:
Signature: keyId="Test",algorithm="rsa-sha256",headers="user", signature="DH7DFavH1j76Hk4oiqTW1hAcmfLHq/1NcFZbgzvtJuLyber7mnih0jBRbvqe7iI34pi6PNZhXLnzvSm6y3e966n4q/yVWwA7Eb17hSkcwcFEiZvzThpM2zjWxRe5fdY3DvjGolBFQJZryx2eF2XzhVS0SowbyWJ/V+bf2GXYF5WvY/3NZczH6X6k58BAdv1Bl7CY0N0LrMbKdCWBDjFCU891B0RzgqaK9XX0z839Lscj6zsTkUh+PzGYvdrLi0CyI36pGUSEzhT/lY2StHR6MFimnXiOc1Y1U0rHnpI09659WDPLPwcCOenQgW4LxsbwQJQ795yJhiGRrRphfqeycg=="
user: denis
And I always get error that signature malformed. What’s wrong with my configuration? Validation on online site where I sign the content are valid, in this development - not. I though my keyid is not corresponding to actual public key, but from my understanding this keyId param not important, but I tried to put there serial number of my public key, sha, etc. Never works
Any help will be highly appreciated!
Thanks,
D