提交 47579ba0 编写于 作者: J jiazhiguang 提交者: jia zhang

Base64 encode the signatrue when sending signature body from server and base64...

Base64 encode the signatrue when sending signature body from server and base64 decode signature when retriving signature  bodyfrom client
上级 9bffcfcb
......@@ -3,6 +3,7 @@ package client
import (
"bytes"
"crypto/tls"
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
......@@ -91,7 +92,12 @@ func (c *pkcs1Client) Sign(data []byte) (signature []byte, publicKey []byte, err
glog.Errorf("failed to unmarshal sign response,%v", err)
return nil, nil, err
}
return []byte(payload.Signature), []byte(payload.PublicKey), nil
decode, err := base64.StdEncoding.DecodeString(payload.Signature)
if err != nil {
glog.Errorf("failed to decode signature,%v", err)
return nil, nil, err
}
return decode, []byte(payload.PublicKey), nil
}
func (c *pkcs1Client) GetStandard() SignStandard {
......
......@@ -5,6 +5,7 @@ import (
"crypto/rand"
"crypto/rsa"
"crypto/sha256"
"encoding/base64"
"io/ioutil"
"net/http"
......@@ -34,7 +35,7 @@ func (s *ApiServer) pkcs1Handler(c *gin.Context) {
return
}
payload.Signature = string(signedBytes)
payload.Signature = base64.StdEncoding.EncodeToString(signedBytes)
bytes, err := ioutil.ReadFile(s.publicKeyFilePath)
if err != nil {
glog.Errorf("failed to parse public key, public key path: %s, err:%v", s.publicKeyFilePath, err.Error())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册