utils

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//DefaultPrivateKeyPwd default private pwd
	DefaultPrivateKeyPwd = ""
	//DefaultWorkDirectory default work dir
	DefaultWorkDirectory = "./"
	//DefaultCRLNextTime default crl next time
	DefaultCRLNextTime = time.Hour * 24
	//DefaultTokenSecretKey default token secret key
	DefaultTokenSecretKey = "1045836262777123654"
)

Variables

View Source
var CaType2NameMap = map[CaType]string{
	TLS:         "tls",
	SIGN:        "sign",
	SINGLE_ROOT: "single_root",
	DOUBLE_ROOT: "double_root",
}

CaType2NameMap Ca type to string name

View Source
var HashType2NameMap = map[crypto.HashType]string{
	crypto.HASH_TYPE_SM3:      "SM3",
	crypto.HASH_TYPE_SHA256:   "SHA256",
	crypto.HASH_TYPE_SHA3_256: "SHA3_256",
}
View Source
var Name2CaTypeMap = map[string]CaType{
	"tls":         TLS,
	"sign":        SIGN,
	"single_root": SINGLE_ROOT,
	"double_root": DOUBLE_ROOT,
}

Name2CaTypeMap string name to ca type

View Source
var Name2HashTypeMap = map[string]crypto.HashType{
	"SM3":      crypto.HASH_TYPE_SM3,
	"SHA256":   crypto.HASH_TYPE_SHA256,
	"SHA3_256": crypto.HASH_TYPE_SHA3_256,
}

Functions

func GetConfigEnv

func GetConfigEnv() string

GetConfigEnv --Specify the path and name of the configuration file (Env)

func GetDBConfig

func GetDBConfig() string

GetDBConfig --Get DB config from config file.

func GetFlagPath

func GetFlagPath() string

GetFlagPath --Specify the path and name of the configuration file (flag)

func InitConfig

func InitConfig(configPath string)

InitConfig --init config

func SetConfig

func SetConfig(envPath string)

SetConfig --Set config path and file name

Types

type AccessControlConf

type AccessControlConf struct {
	AppRole string `mapstructure:"app_role"`
	AppId   string `mapstructure:"app_id"`
	AppKey  string `mapstructure:"app_key"`
}

type AllConfig

type AllConfig struct {
	LogConf             *loggers.LogConifg   `mapstructure:"log_config"`
	DBConf              *DBConfig            `mapstructure:"db_config"`
	BaseConf            *BaseConf            `mapstructure:"base_config"`
	RootCaConf          *CaConfig            `mapstructure:"root_config"`
	IntermediateCaConfs []*ImCaConfig        `mapstructure:"intermediate_config"`
	AccessControlConfs  []*AccessControlConf `mapstructure:"access_control_config"`
	Pkcs11Conf          *Pkcs11Conf          `mapstructure:"pkcs11_config"`
}

func GetAllConf

func GetAllConf() (*AllConfig, error)

Get all conf

func GetAllConfig

func GetAllConfig() *AllConfig

func (*AllConfig) GetAccessControlConf

func (ac *AllConfig) GetAccessControlConf() []*AccessControlConf

func (*AllConfig) GetBaseConf

func (ac *AllConfig) GetBaseConf() *BaseConf

func (*AllConfig) GetCaType

func (ac *AllConfig) GetCaType() string

func (*AllConfig) GetCanIssueCa

func (ac *AllConfig) GetCanIssueCa() bool

func (*AllConfig) GetDBConf

func (ac *AllConfig) GetDBConf() *DBConfig

func (*AllConfig) GetDefaultCertValidTime

func (ac *AllConfig) GetDefaultCertValidTime() time.Duration

func (*AllConfig) GetDefaultDomain

func (ac *AllConfig) GetDefaultDomain() string

func (*AllConfig) GetDefaultExpireMonth

func (ac *AllConfig) GetDefaultExpireMonth() int

func (*AllConfig) GetDefaultExpireYear

func (ac *AllConfig) GetDefaultExpireYear() int

func (*AllConfig) GetHashType

func (ac *AllConfig) GetHashType() string

func (*AllConfig) GetIntermediateConf

func (ac *AllConfig) GetIntermediateConf() []*ImCaConfig

func (*AllConfig) GetKeyType

func (ac *AllConfig) GetKeyType() string

func (*AllConfig) GetLogConf

func (ac *AllConfig) GetLogConf() *loggers.LogConifg

func (*AllConfig) GetPkcs11Conf

func (ac *AllConfig) GetPkcs11Conf() *Pkcs11Conf

func (*AllConfig) GetPkcs11Enabled

func (ac *AllConfig) GetPkcs11Enabled() bool

func (*AllConfig) GetProvideServiceFor

func (ac *AllConfig) GetProvideServiceFor() []string

func (*AllConfig) GetRootCertConf

func (ac *AllConfig) GetRootCertConf() []*CertConf

func (*AllConfig) GetRootConf

func (ac *AllConfig) GetRootConf() *CaConfig

func (*AllConfig) GetRootCsrConf

func (ac *AllConfig) GetRootCsrConf() *CsrConf

func (*AllConfig) GetServerPort

func (ac *AllConfig) GetServerPort() string

func (*AllConfig) IsAccessControl

func (ac *AllConfig) IsAccessControl() bool

func (*AllConfig) IsKeyEncrypt

func (ac *AllConfig) IsKeyEncrypt() bool

type BaseConf

type BaseConf struct {
	ServerPort  string `mapstructure:"server_port"`
	CaType      string `mapstructure:"ca_type"`
	ExpireYear  int    `mapstructure:"expire_year"`
	ExpireMonth int    `mapstructure:"expire_month"`
	// For test
	CertValidTime     time.Duration `mapstructure:"cert_valid_time"`
	HashType          string        `mapstructure:"hash_type"`
	KeyType           string        `mapstructure:"key_type"`
	CanIssueca        bool          `mapstructure:"can_issue_ca"`
	ProvideServiceFor []string      `mapstructure:"provide_service_for"`
	IsKeyEncrypt      bool          `mapstructure:"key_encrypt"`
	AccessControl     bool          `mapstructure:"access_control"`
	DefaultDomain     string        `mapstructure:"default_domain"`
}

type CaConfig

type CaConfig struct {
	CsrConf  *CsrConf    `mapstructure:"csr"`
	CertConf []*CertConf `mapstructure:"cert"`
}

type CaType

type CaType int
const (
	//TLS catype of tls
	TLS CaType = iota + 1
	//SIGN catype of sign
	SIGN
	//SINGLE_ROOT catype of single_root
	SINGLE_ROOT
	//DOUBLE_ROOT catype of double_root
	DOUBLE_ROOT
)

type CertConf

type CertConf struct {
	CertType       string `mapstructure:"cert_type"`
	CertPath       string `mapstructure:"cert_path"`
	PrivateKeyPath string `mapstructure:"private_key_path"`
	KeyId          string `mapstructure:"key_id"`
}

type CsrConf

type CsrConf struct {
	CN       string `mapstructure:"CN"`
	O        string `mapstructure:"O"`
	OU       string `mapstructure:"OU"`
	Country  string `mapstructure:"country"`
	Locality string `mapstructure:"locality"`
	Province string `mapstructure:"province"`
}

type DBConfig

type DBConfig struct {
	User     string `mapstructure:"user"`
	Password string `mapstructure:"password"`
	IP       string `mapstructure:"ip"`
	Port     string `mapstructure:"port"`
	DbName   string `mapstructure:"dbname"`
}

DBConfig /

type ImCaConfig

type ImCaConfig struct {
	CsrConf *CsrConf `mapstructure:"csr"`
	KeyId   string   `mapstructure:"key_id"`
}

type Pkcs11Conf

type Pkcs11Conf struct {
	Enabled          bool   `mapstructure:"enabled"`
	Library          string `mapstructure:"library"`
	Label            string `mapstructure:"label"`
	Password         string `mapstructure:"password"`
	SessionCacheSize int    `mapstructure:"session_cache_size"`
	Hash             string `mapstructure:"hash"`
}

Jump to

Keyboard shortcuts

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