gosunetca

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: MIT Imports: 10 Imported by: 0

README

gosunetCA

Go Reference

Installation

go get github.com/masv3971/gosunetca

Examples

Signing documents
package main

import (
   "github.com/masv3971/gosunetca"
)

func main() {
   client, err := New(Config{
       ServerURL: "https://ca.example.com",
       Token:     "d0f2a35a-b8d2-11ed-a74f-a7526ac1d573",
       UserAgent: "blackbox-app/1.0",
   })
   if err != nil {
       panic(err)
   }
   signedDocuments, _, err := client.Sign.Documents(context.Background(), &types.SignRequest{
       Meta: types.SignMetaRequest{
           Version:  1,
           KeyLabel: "Ladok-sign-v1",
           Encoding: "base64",
           KeyType:  "secp256r1",
       },
       Documents: []types.UnsignedDocument{
           {
               ID:   "64d06fbc-b8d3-11ed-a4ed-9b1b4d858581",
               Data: "ZXR0IGRva3VtZW50IGF0dCBzaWduZXJh",
           },
       },
   })
   if err != nil {
       panic(err)
   }

   for _, doc := range signedDocuments.SignatureValues {
       fmt.Println(doc.ID, doc.Signature)
   }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(s interface{}) error

Check checks for validation error

Types

type Client

type Client struct {
	Sign *SignService
	// contains filtered or unexported fields
}

Client is the client for the SUNET CA API

func New

func New(config Config) (*Client, error)

New create a new client

type Config

type Config struct {
	ServerURL string `validate:"required"`
	Token     string `validate:"required"`
	UserAgent string
}

Config is the configuration for the client

type SignService added in v0.0.4

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

SignService is the service for signing

func (*SignService) Documents added in v0.0.4

func (s *SignService) Documents(ctx context.Context, body *types.SignRequest) (*types.SignReply, *http.Response, error)

Documents signs documents

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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