-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add SAN option Signed-off-by: nyagamunene <[email protected]> * Make SAN dynamic Signed-off-by: nyagamunene <[email protected]> * Load config file in main.go Signed-off-by: nyagamunene <[email protected]> * Fix tests Signed-off-by: nyagamunene <[email protected]> * Address comments Signed-off-by: nyagamunene <[email protected]> * Update config file Signed-off-by: nyagamunene <[email protected]> * Update config file Signed-off-by: nyagamunene <[email protected]> * remove street address Signed-off-by: nyagamunene <[email protected]> * Rename should rotate method Signed-off-by: nyagamunene <[email protected]> --------- Signed-off-by: nyagamunene <[email protected]>
- Loading branch information
1 parent
f32758a
commit 3f118b8
Showing
7 changed files
with
161 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (c) Abstract Machines | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package certs | ||
|
||
import ( | ||
"net" | ||
"os" | ||
|
||
"gopkg.in/yaml.v2" | ||
) | ||
|
||
type CAConfig struct { | ||
CommonName string `yaml:"common_name"` | ||
Organization []string `yaml:"organization"` | ||
OrganizationalUnit []string `yaml:"organizational_unit"` | ||
Country []string `yaml:"country"` | ||
Province []string `yaml:"province"` | ||
Locality []string `yaml:"locality"` | ||
StreetAddress []string `yaml:"street_address"` | ||
PostalCode []string `yaml:"postal_code"` | ||
DNSNames []string `yaml:"dns_names"` | ||
IPAddresses []string `yaml:"ip_addresses"` | ||
ValidityPeriod string `yaml:"validity_period"` | ||
} | ||
|
||
func LoadConfig(filename string) (*Config, error) { | ||
file, err := os.Open(filename) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer file.Close() | ||
|
||
var config CAConfig | ||
decoder := yaml.NewDecoder(file) | ||
if err := decoder.Decode(&config); err != nil { | ||
return nil, err | ||
} | ||
return &Config{ | ||
CommonName: config.CommonName, | ||
Organization: config.Organization, | ||
OrganizationalUnit: config.OrganizationalUnit, | ||
Country: config.Country, | ||
Province: config.Province, | ||
Locality: config.Locality, | ||
StreetAddress: config.StreetAddress, | ||
PostalCode: config.PostalCode, | ||
DNSNames: config.DNSNames, | ||
IPAddresses: parseIPs(config.IPAddresses), | ||
}, nil | ||
} | ||
|
||
func parseIPs(ipStrings []string) []net.IP { | ||
var ips []net.IP | ||
for _, ipString := range ipStrings { | ||
if ip := net.ParseIP(ipString); ip != nil { | ||
ips = append(ips, ip) | ||
} | ||
} | ||
return ips | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright (c) Abstract Machines | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
common_name: "AbstractMachines_Selfsigned_ca" | ||
organization: | ||
- "AbstractMacines" | ||
organizational_unit: | ||
- "AbstractMachines_ca" | ||
country: | ||
- "France" | ||
province: | ||
- "Paris" | ||
locality: | ||
- "Quai de Valmy" | ||
postal_code: | ||
- "75010 Paris" | ||
dns_names: | ||
- "localhost" | ||
ip_addresses: | ||
- "localhost" | ||
validity_period: "8760h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.