pki

package module
v0.0.0-...-8eba0c9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2020 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package pki is a pure go client for dealing with Ankr KMS.it includes a high-level API for easy generate private key and public key Warning a new client will be invalid, when the token is invalid, it makes us to create a new client, please care it.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func (*Client) Request

func (c *Client) Request(cfg *Config) (*Response, error)
Example
package main

import (
	"github.com/Ankr-network/go-kms/pki"
)

func main() {
	cc, err := pki.NewPkiClient("192.168.39.113:30401", "ankr-pki")
	if err != nil {
		// handle with error
		return
	}
	if rsp, err := cc.Request(&pki.Config{Ttl: "24h", CommonName: "test.ankr.com"}); err != nil {
		// handle with error
		return
	} else {
		_ = rsp
	}
}

func (*Client) Revoke

func (c *Client) Revoke(serialNumber string) error
Example
package main

import (
	"github.com/Ankr-network/go-kms/pki"
)

func main() {
	cc, err := pki.NewPkiClient("192.168.39.113:30401", "ankr-pki")
	if err != nil {
		// handle with error
		return
	}
	if err := cc.Revoke("4a:ad:19:51:7a:47:5e:13:83:26:13:f2:43:25:ea:4a:36:b7:ae:9f"); err != nil {
		// handle with error
		return
	}
}

type Config

type Config struct {
	CommonName string `json:"common_name"`
	// format: "24h"
	Ttl string `json:"ttl"`
}

type Handler

type Handler interface {
	// request private key and public key
	Request(cfg *Config) (*Response, error)
	// revoke certificates by serial number
	Revoke(serialNumber string) error
}

func NewPkiClient

func NewPkiClient(kmsAddr, appRole string) (Handler, error)

NewPkiClient create pki client kmsAddr remote kms service address appRole the kms provide assign you application role

type KmsError

type KmsError struct {
	Errors []string `json:"errors"`
}

type Response

type Response struct {
	// RSA private key
	PriKey string
	// RSA public key
	Pubkey string
	// the serial number of private key, revoke it by serial number
	SN string
}

type RevokeRequest

type RevokeRequest struct {
	SerialNumber string `json:"serial_number"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL