add sort in indextxt
This commit is contained in:
parent
b365790dec
commit
1cbcc9fe73
1 changed files with 10 additions and 4 deletions
|
@ -8,6 +8,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
@ -175,7 +176,6 @@ func (openVPNPKI *OpenVPNPKI) getExistCert(name string) (data ClientCert, err er
|
||||||
func (openVPNPKI *OpenVPNPKI) BuildKeyPairClient(commonName string) (err error) {
|
func (openVPNPKI *OpenVPNPKI) BuildKeyPairClient(commonName string) (err error) {
|
||||||
|
|
||||||
switch *StorageBackend {
|
switch *StorageBackend {
|
||||||
|
|
||||||
case "kubernetes.secrets":
|
case "kubernetes.secrets":
|
||||||
// check certificate exists
|
// check certificate exists
|
||||||
_, err = openVPNPKI.secretGetByLabels("name=" + commonName)
|
_, err = openVPNPKI.secretGetByLabels("name=" + commonName)
|
||||||
|
@ -215,7 +215,6 @@ func (openVPNPKI *OpenVPNPKI) BuildKeyPairClient(commonName string) (err error)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
case "filesystem":
|
case "filesystem":
|
||||||
|
|
||||||
if checkUserExist(commonName) {
|
if checkUserExist(commonName) {
|
||||||
|
@ -459,10 +458,17 @@ func (openVPNPKI *OpenVPNPKI) indexTxtUpdate() (err error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var body []string
|
var body []string
|
||||||
for _, line := range indexTxtFromFile{
|
keys := make([]string, 0)
|
||||||
body = append(body, fmt.Sprintf("%s\t%s\t%s\t%s\t%s\t%s\n", line.Flag, line.ExpirationDate, line.RevocationDate, line.SerialNumber, line.Filename, line.DistinguishedName))
|
for k, _ := range indexTxtFromFile {
|
||||||
|
keys = append(keys, k)
|
||||||
}
|
}
|
||||||
|
sort.Strings(keys)
|
||||||
|
for _, k := range keys {
|
||||||
|
body = append(body, fmt.Sprintf("%s\t%s\t%s\t%s\t%s\t%s\n", indexTxtFromFile[k].Flag, indexTxtFromFile[k].ExpirationDate, indexTxtFromFile[k].RevocationDate, indexTxtFromFile[k].SerialNumber, indexTxtFromFile[k].Filename, indexTxtFromFile[k].DistinguishedName))
|
||||||
|
}
|
||||||
|
|
||||||
err = fWrite(*EasyrsaDirPath+"/pki/index.txt", strings.Join(body, ""))
|
err = fWrite(*EasyrsaDirPath+"/pki/index.txt", strings.Join(body, ""))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue