Hi, how did you get about this? I am facing the same issue.

On Friday, October 9, 2015 at 11:17:35 PM UTC-7 Charles Haynes wrote:

> A couple of suggestions.
>
> First, is it possible to walk through the code in the crypto library to 
> see why it's failing to validate?
>
> Second, is it possible to do an encode on the go side to see what the 
> crypto library might be expecting? Do an a/b comparison of the same encode 
> done in node and in Go and see how they are different. See if you can 
> simplify the failing example until they both give the same result, then 
> work forward to see where they differ.
>
> Good luck.
>
> On 10 October 2015 at 08:14, Gabriel Vincent Kho <gabrie...@gmail.com> 
> wrote:
>
>> Ya, I've printed those. The error is just "
>>    crypto/rsa: verification error". Not exactly the most helpful.
>>
>>
>> On Friday, October 9, 2015 at 1:04:50 PM UTC-7, Joe Taber wrote:
>>>
>>> I would guess a good starting point for debugging would be to actually 
>>> print the returned errors.
>>>
>>> The 'error' type doesn't just indicate the presence of a problem, but it 
>>> usually also contains details of the problem. E.g. change to 
>>> `fmt.Println("cannot verify:", err)`.
>>>
>>> I'm not familiar with the crypto library so maybe someone else could 
>>> help you once you have these details.
>>>
>>> On Friday, October 9, 2015 at 2:02:52 PM UTC-5, Gabriel Vincent Kho 
>>> wrote:
>>>>
>>>> I'm creating a signature in javascript using a private key, and I want 
>>>> to verify it in my server using golang. However, I am unable to verify the 
>>>> signature.
>>>>
>>>> Here is how I create the signature in golang using forge.js
>>>>
>>>>      var md = forge.md.sha256.create();
>>>>      md.update(randomString, 'utf8');
>>>>      var signature = privateKey.sign(md);
>>>>      signature = forge.util.encode64(signature);
>>>>      formData.append("sig", signature);
>>>>
>>>> I pass it over using multiform, and then on my golang server using the 
>>>> crypto library, I read it out and try to verify it this way
>>>>
>>>>     h := sha256.New()
>>>> digest := h.Sum(nil)
>>>>
>>>> signature, err := b64.StdEncoding.DecodeString(string(sig))
>>>> if err != nil {
>>>> fmt.Println("COULD NOT DECODE")
>>>> return
>>>> }
>>>> cert, err := x509.ParseCertificate(certBytes)
>>>> if err != nil {
>>>> return
>>>> }
>>>> pubkey := cert.PublicKey.(*rsa.PublicKey)
>>>> err = rsa.VerifyPKCS1v15(pubkey, crypto.SHA256, digest, signature)
>>>> if err != nil {
>>>> fmt.Println("COULD NOT VERIFY")
>>>> return
>>>> }
>>>>     
>>>> I keep failing to verify the signature. I'm kinda lost as to how to 
>>>> even debug this.
>>>>
>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to golang-nuts...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/24db1468-c915-43f8-9f43-3c3dd0ba8502n%40googlegroups.com.

Reply via email to