You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: authenticate_callback.go
    path of file: ./repos/DocHub/vendor/github.com/denverdino/aliyungo/oss
    
    the code of the file until where you have to start completion: package oss

import (
	"encoding/base64"
	"regexp"
	"errors"
	"strings"
	"sync"
	"net/http"
	"io/ioutil"
	"crypto/x509"
	"crypto/rsa"
	"crypto"
	"fmt"
	"encoding/pem"
	"crypto/md5"
)

type authenticationType struct {
	lock        *sync.RWMutex
	certificate map[string]*rsa.PublicKey
}

var (
	authentication = authenticationType{lock:&sync.RWMutex{}, certificate: map[string]*rsa.PublicKey{}}
	urlReg = regexp.M
    
func AuthenticateCallBack(pubKeyUrl, reqUrl, reqBody, authorization string) error {
	//获取证书url
	keyURL, err := base64.URLEncoding.DecodeString(pubKeyUrl)
	if err != nil {
		return err
	}
	url := string(keyURL)
	//判断证书是否来自于阿里云
	if !urlReg.Match(keyURL) {
		return errors.New("证书地址有误。")
	}
	//获取文件名
	rs := []rune(url)
	filename := string(rs[strings.LastIndex(url, "/"): len(rs) - 1])
	authentication.lock.RLock()
	certificate := authentication.certificate[filename]
	authentication.lock.RUnlock()
	fmt.Println("准备证书")
	//内存中没有证书，下载
	if certificate == nil {
		authentication.lock.Lock()
		res, err := http.Get(url)
		if err != nil {
			return err
		}
		defer res.Body.Close()
		body, err := ioutil.ReadAll(res.Body)
		if err != nil {
			return err
		}
		fmt.Println(string(body))
		block, _ := pem.Decode(body)
		if block == nil {
			return errors.New("证书有误。")
		}
		pubKey, err := x509.ParsePKIXPublicKey(block.Bytes)
		if err != nil {
			return err
		}
		certificate = pubKey.(*rsa.PublicKey)
		authentication.certificate[filename] = certificate
		authentication.lock.Unlock()
	}
	//证书准备完毕，开始验证
	fmt.Println("准备开始验证")
	//解析签名
	signature, err := base64.StdEncoding.DecodeString(authorization)
	if err != nil {
		return err
	}
	hashed := md5.New()
	hashed.Write([]byte(reqUrl + "\n" + reqBody))
	fmt.Println(reqUrl + "\n" + reqBody)
	if err := rsa.VerifyPKCS1v15(certificate, crypto.MD5, hashed.Sum(nil), signature); err != nil {
		return err
	}
	//验证通过
	return nil
}