Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Added CAPATH to the cmd parameter #41

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ count.out
coverage.out
DoNotUseThisCAPATHTestOnly/
docs-test/
cover.out
cover.out
store
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ docker-image:
docker build -t goca-rest-api:latest .

lint:
golangci-lint run -e gosec
golangci-lint run -e gosec

start:
go run rest-api/main.go -capath="./store" -p 81
6 changes: 3 additions & 3 deletions _storage/storage.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2020, Kairo de Araujo
// # Copyright (c) 2020, Kairo de Araujo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -60,7 +60,7 @@ func savePEMKey(fileName string, key *rsa.PrivateKey) {
checkError(err)

var privateKey = &pem.Block{
Type: "PRIVATE KEY",
Type: "RSA PRIVATE KEY",
Bytes: x509.MarshalPKCS1PrivateKey(key),
}

Expand All @@ -73,7 +73,7 @@ func savePublicPEMKey(fileName string, pubkey rsa.PublicKey) {
checkError(err)

var pemkey = &pem.Block{
Type: "PUBLIC KEY",
Type: "RSA PUBLIC KEY",
Bytes: asn1Bytes,
}

Expand Down
239 changes: 167 additions & 72 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ const docTemplate = `{
"CA"
],
"summary": "Certificate Authorities (CA) Information based in Common Name",
"parameters": [
{
"type": "string",
"description": "Common Name",
"name": "cn",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
Expand Down Expand Up @@ -140,6 +149,15 @@ const docTemplate = `{
"CA/{CN}/Certificates"
],
"summary": "List all Certificates managed by a certain Certificate Authority",
"parameters": [
{
"type": "string",
"description": "Common Name of the Certificate Authority",
"name": "cn",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
Expand Down Expand Up @@ -174,6 +192,13 @@ const docTemplate = `{
],
"summary": "CA issue new certificate",
"parameters": [
{
"type": "string",
"description": "Common Name of the Certificate Authority",
"name": "cn",
"in": "path",
"required": true
},
{
"description": "Add new Certificate Authority or Intermediate Certificate Authority",
"name": "ca",
Expand Down Expand Up @@ -216,6 +241,22 @@ const docTemplate = `{
"CA/{CN}/Certificates"
],
"summary": "Get information about a Certificate",
"parameters": [
{
"type": "string",
"description": "Common Name of the Certificate Authority",
"name": "cn",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Common Name of Certificate",
"name": "certificate_cn",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
Expand Down Expand Up @@ -249,6 +290,22 @@ const docTemplate = `{
"CA/{CN}/Certificates"
],
"summary": "CA revoke a existent certificate managed by CA",
"parameters": [
{
"type": "string",
"description": "Common Name of the Certificate Authority",
"name": "cn",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Common Name of Certificate",
"name": "certificate_cn",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
Expand Down Expand Up @@ -427,77 +484,6 @@ const docTemplate = `{
}
}
},
"goca.Identity": {
"type": "object",
"properties": {
"country": {
"description": "Country (two letters)",
"type": "string",
"example": "NL"
},
"dns_names": {
"description": "DNS Names list",
"type": "array",
"items": {
"type": "string"
},
"example": [
"ca.example.com",
"root-ca.example.com"
]
},
"email": {
"description": "Email Address",
"type": "string",
"example": "sec@company.com"
},
"intermediate": {
"description": "Intermendiate Certificate Authority (default is false)",
"type": "boolean",
"example": false
},
"ip_addresses": {
"description": "IP Address list",
"type": "array",
"items": {
"type": "array",
"items": {
"type": "integer"
}
}
},
"key_size": {
"description": "Key Bit Size (defaul: 2048)",
"type": "integer",
"example": 2048
},
"locality": {
"description": "Locality name",
"type": "string",
"example": "Noord-Brabant"
},
"organization": {
"description": "Organization name",
"type": "string",
"example": "Company"
},
"organization_unit": {
"description": "Organizational Unit name",
"type": "string",
"example": "Security Management"
},
"province": {
"description": "Province name",
"type": "string",
"example": "Veldhoven"
},
"valid": {
"description": "Minimum 1 day, maximum 825 days -- Default: 397",
"type": "integer",
"example": 365
}
}
},
"models.CABody": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -539,6 +525,16 @@ const docTemplate = `{
"intermediate": {
"type": "boolean"
},
"ip_addresses": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"127.0.0.1",
"192.168.2.1"
]
},
"issue_date": {
"type": "string",
"example": "2021-01-06 10:31:43 +0000 UTC"
Expand Down Expand Up @@ -587,6 +583,16 @@ const docTemplate = `{
"files": {
"$ref": "#/definitions/goca.Certificate"
},
"ip_addresses": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"127.0.0.1",
"192.168.0.1"
]
},
"issue_date": {
"type": "string",
"example": "2021-01-06 10:31:43 +0000 UTC"
Expand All @@ -598,7 +604,96 @@ const docTemplate = `{
}
},
"models.Payload": {
"type": "object"
"type": "object",
"required": [
"common_name",
"identity"
],
"properties": {
"common_name": {
"type": "string",
"example": "root-ca"
},
"identity": {
"$ref": "#/definitions/models.PayloadIdentity"
},
"parent_common_name": {
"type": "string",
"example": "root-ca"
}
}
},
"models.PayloadIdentity": {
"type": "object",
"properties": {
"country": {
"description": "Country (two letters)",
"type": "string",
"example": "NL"
},
"dns_names": {
"description": "DNS Names list",
"type": "array",
"items": {
"type": "string"
},
"example": [
"ca.example.com",
"root-ca.example.com"
]
},
"email": {
"description": "Email Address",
"type": "string",
"example": "sec@company.com"
},
"intermediate": {
"description": "Intermendiate Certificate Authority (default is false)",
"type": "boolean",
"example": false
},
"ip_addresses": {
"description": "IP Address list",
"type": "array",
"items": {
"type": "string"
},
"example": [
"127.0.0.1",
"192.168.0.1"
]
},
"key_size": {
"description": "Key Bit Size (defaul: 2048)",
"type": "integer",
"example": 2048
},
"locality": {
"description": "Locality name",
"type": "string",
"example": "Noord-Brabant"
},
"organization": {
"description": "Organization name",
"type": "string",
"example": "Company"
},
"organization_unit": {
"description": "Organizational Unit name",
"type": "string",
"example": "Security Management"
},
"province": {
"description": "Province name",
"type": "string",
"example": "Veldhoven"
},
"valid": {
"description": "Minimum 1 day, maximum 825 days -- Default: 397",
"type": "integer",
"example": 365
}
}
},
"models.ResponseCA": {
"type": "object",
Expand Down
Loading