x509utils

package
v0.0.0-...-b44964e Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: Apache-2.0, Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var (
	CertCN = ""

	ATCASlot     = 0
	CertValidity time.Duration
)

Functions

func GeneratePrivateKey

func GeneratePrivateKey(ctx context.Context, keyType CertType, useATCA bool, devConn dev.DevConn, devConf *dev.DevConf, devInfo *dev.GetInfoResult) (crypto.Signer, []byte, []byte, error)

func LoadCertAndKey

func LoadCertAndKey(certFile, keyFile string) ([]byte, []byte, crypto.Signer, []byte, []byte, error)

func LoadOrGenerateCertAndKey

func LoadOrGenerateCertAndKey(ctx context.Context, certType CertType, certFile, keyFile string, certTmpl *x509.Certificate, useATCA bool,
	devConn dev.DevConn, devConf *dev.DevConf, devInfo *dev.GetInfoResult) (
	[]byte, []byte, crypto.Signer, []byte, []byte, error)

func PrintCertInfo

func PrintCertInfo(certDERBytes []byte)

func WriteAndUploadFile

func WriteAndUploadFile(ctx context.Context,
	fileType string, data []byte, customName, defaultName string,
	devConn dev.DevConn) (string, error)

func WritePEM

func WritePEM(derBytes []byte, blockType string, outputFileName string) error

func WritePubKey

func WritePubKey(pubKey *ecdsa.PublicKey, outputFileName string) error

Types

type AttributeTypeAndValue

type AttributeTypeAndValue struct {
	// Type is the attribute type
	Type string
	// Value is the attribute value
	Value string
}

AttributeTypeAndValue represents an attributeTypeAndValue from https://tools.ietf.org/html/rfc4514

type CertType

type CertType string
const (
	CertTypeRSA   CertType = "RSA"
	CertTypeECDSA          = "ECDSA"
)

func PickCertType

func PickCertType(devInfo *dev.GetInfoResult) (CertType, bool, error)

type DN

type DN struct {
	RDNs []*RelativeDN
}

DN represents a distinguishedName from https://tools.ietf.org/html/rfc4514

func ParseDN

func ParseDN(str string) (*DN, error)

ParseDN returns a distinguishedName or an error

func (*DN) ToPKIXName

func (dn *DN) ToPKIXName() (*pkix.Name, error)

type RelativeDN

type RelativeDN struct {
	Attributes []*AttributeTypeAndValue
}

RelativeDN represents a relativeDistinguishedName from https://tools.ietf.org/html/rfc4514

Jump to

Keyboard shortcuts

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