Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/develar/go-pkcs12
https://github.com/develar/go-pkcs12
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/develar/go-pkcs12
- Owner: develar
- License: mit
- Created: 2018-11-11T07:30:56.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-15T14:35:53.000Z (almost 6 years ago)
- Last Synced: 2024-10-14T21:57:14.897Z (22 days ago)
- Language: Go
- Size: 35.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Introduce
This package code is derived from github.com/AGWA-forks/golang-crypto , and moved to be a independent package for PKCS12 encode and decode!
## Demo
```go
package mainimport (
"io/ioutil"
"log"
"strconv""github.com/lotus-wu/go-pkcs12"
)func main() {
pfxData, _ := ioutil.ReadFile("a.p12")
pv, cer, err := pkcs12.DecodeAll(pfxData, "123456")
if err != nil {
log.Println(err)
return
}
log.Println(pv)
log.Println(cer)id := int64(0)
for _, v := range cer {
filename := "test" + strconv.FormatInt(id, 10) + ".cer"
ioutil.WriteFile(filename, v.Raw, 0666)
id += 1
}pfxDataNew, _ := pkcs12.Encode(pv, cer[0], cer[1:], "123456")
ioutil.WriteFile("1.p12", pfxDataNew, 0666)
}
```