Open carlol opened 2 years ago
Have you modifed the application.properties and test-application.properties file with the path to the pem file. The PEM file must be named as the apiKey that you were given as this is how it is extracted.
Hi,
yes we added the file as-is and put in the properties its absolute path (see the image).
we get the following error: org.bouncycastle.openssl.PEMException: problem creating RSA private key: java.lang.IllegalArgumentException: failed to construct sequence from byte[]: corrupted stream detected
We imported the project in IntelliJ lik a maven project and we added the absolute path to
Thank you in advance for your help,
Best regards,
CL
Hi, I'm Edoardo, Carlo's colleague. I work on iOS and I'm trying to implement your APIs. I'm not using the Java SDK (not possible on iOS), but I'm trying to translate the developer guide on your website in Swift. I'm having issues with the .pem file. Every RSA library I tried it seems to not recognize the private key as a valid one. I'm trying with "SwiftyRSA", "CryptorRSA" (two of the most popular) without any good result. I was wondering if you have had feedback from other iOS developers, or you can try to help us in other ways.
Basically, I'm trying to replicate the Java code on your website in this way:
let stringDate = stringDateText.data(using: .utf8)!
let myPlaintext = CryptorRSA.createPlaintext(with: stringDate)
let privateKey = try CryptorRSA.createPrivateKey(withPEMNamed: API_KEY, in: .main)
let signedData = try myPlaintext.signed(with: privateKey, algorithm: .sha256)
let stringSig = signedData?.base64String
var sig = "Signature keyId="
sig.append("\"")
sig.append(API_KEY)
sig.append("\"")
sig.append(",algorithm=\"rsa-sha256\",signature=\"")
sig.append(stringSig!)
sig.append("\"")
The error I'm receiving is this: "Error code: -9999(0x-270F), Couldn't create key reference from key data"
Could you give a look at this code, please? Am I missing something? Thank you.
There is something wrong with the key and we are investigating internally.
Hi, after trying a little bit more we finally managed to get it work with the key we have, on iOS and Android. Probably there's a problem in the Java code you provide, because now we signed successfully the request with Swift and Kotlin.
Yes its something wrong inside the bouncycastle pem routines. Glad you got it working on iOS/Android. Still under investigation.
The pem file you have is actually a key. So to convert it to a pem do the following.. mv existing.pem existing.key openssl rsa -in existing.key -text > existing.pem
ok but it still is a private key, is ok for us to store it in the client applications?
Please contact Radioplayer directly regarding your usage of your key.
Hi, the issue was solved using the OpenSSL 1.1.1i
version.
If you face this problem, probably the key given by Radioplayer was generated with higher version of OpenSSL and the readKey method probably fails because it doesn't recognize the bytes.
Just install the given OpenSSL version and rename the given key with a .key extension and do the command:
openssl rsa -in <yourkey.key> -out <yourkey.pem>
Hope this helps!
Hi, I've downloaded the project and added the trial pem file and api_key but when I run the tests I get "problem creating RSA private key: java.lang.IllegalArgumentException: failed to construct sequence from byte[]: corrupted stream detected".
I'm doing something wrong or there is some missing update to the code?
Best regards.