Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Acme Downloader
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Geant DevOps
Acme Downloader
Commits
7b5216d2
Unverified
Commit
7b5216d2
authored
4 years ago
by
Max Adamo
Browse files
Options
Downloads
Patches
Plain Diff
rollback attempt to use crypt library
parent
8bab8ad5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
build.sh
+12
-12
12 additions, 12 deletions
build.sh
main.go
+47
-2
47 additions, 2 deletions
main.go
with
59 additions
and
14 deletions
build.sh
+
12
−
12
View file @
7b5216d2
...
...
@@ -30,17 +30,17 @@ if [ $? -gt 0 ]; then
fi
echo
""
while
true
;
do
read
-p
"Do you wish to run upx against
${
BIN_NAME
}
? (y/n) "
yn
case
$yn
in
[
Yy]
*
)
echo
""
run_upx
break
;;
[
Nn]
*
)
break
;;
*
)
echo
"Please answer yes or no."
;;
esac
done
#
while true; do
#
read -p "Do you wish to run upx against ${BIN_NAME}? (y/n) " yn
#
case $yn in
#
[Yy]*)
#
echo ""
#
run_upx
#
break
#
;;
#
[Nn]*) break ;;
#
*) echo "Please answer yes or no." ;;
#
esac
#
done
echo
-e
"
\n
the binary was compiled and it is avilable as:
\n
-
${
GOPATH
}
/bin/
${
BIN_NAME
}
\n
"
This diff is collapsed.
Click to expand it.
main.go
+
47
−
2
View file @
7b5216d2
...
...
@@ -40,6 +40,8 @@ var (
tmpKeyDestination
string
certTmpDir
string
opensslBinary
string
key
*
x509
.
Certificate
cert
*
x509
.
Certificate
)
// app clean and exit
...
...
@@ -111,6 +113,7 @@ func checkCertificates(dnsname string, certificate string, fullchain string, ca
return
false
}
}
cert
,
err
:=
x509
.
ParseCertificate
(
block
.
Bytes
)
if
err
!=
nil
{
if
fail
==
true
{
...
...
@@ -163,7 +166,6 @@ func checkCertificates(dnsname string, certificate string, fullchain string, ca
}
}
return
true
}
// check if priv key matches the publick key
...
...
@@ -202,6 +204,47 @@ func checkPrivkey(privkey string, pubcert string, opensslbinary string, fail boo
return
true
}
// check if priv key matches the publick key
/*
func checkPrivkey(privkey string, pubkey string, fail bool) bool {
// extract data from public key
pubkeyByte, errpubkey := ioutil.ReadFile(pubkey)
if errpubkey != nil {
fmt.Printf("[ERR] reading private key %v: %v\n", pubkey, errpubkey)
appExit(255)
}
block, _ := pem.Decode(pubkeyByte)
cert, _ = x509.ParseCertificate(block.Bytes)
rsaPublicKey := cert.PublicKey.(*rsa.PublicKey)
rsaPublicKeyString := fmt.Sprintf(rsaPublicKey.N.String())
// extract data from private key
privkeyByte, errprivkey := ioutil.ReadFile(privkey)
if errprivkey != nil {
fmt.Printf("[ERR] reading private key %v: %v\n", privkey, errprivkey)
appExit(255)
}
fmt.Printf("primo passaggio\n")
keyBlock, _ := pem.Decode(privkeyByte)
key, _ = x509.ParseCertificate(keyBlock.Bytes)
rsaPrivateKey := key.PublicKey.(*rsa.PrivateKey)
rsaPrivateKeyString := fmt.Sprintf(rsaPrivateKey.N.String())
fmt.Printf("primo passaggio")
if rsaPublicKeyString != rsaPrivateKeyString {
if fail == true {
fmt.Printf("[ERR] the private key %v does not match the the public key %v\n", privkey, pubkey)
appExit(255)
} else {
return false
}
}
return true
}
*/
// get redis key
func
GetRedisKey
(
redisurl
string
,
redistoken
string
)
string
{
client
:=
&
http
.
Client
{}
...
...
@@ -427,6 +470,7 @@ Options:
// check if there is a certificate installed and it is valid
existingCert
:=
checkCertificates
(
CertName
,
certificateDestination
,
fullchainDestination
,
caDestination
,
keyDestination
,
Days
,
false
)
// existingKey := checkPrivkey(keyDestination, certificateDestination, false)
existingKey
:=
checkPrivkey
(
keyDestination
,
certificateDestination
,
opensslBinary
,
false
,
silent
)
if
existingCert
==
true
&&
existingKey
==
true
{
fmt
.
Printf
(
"[INFO] the certificate is still valid
\n
"
)
...
...
@@ -444,7 +488,8 @@ Options:
WriteToFile
(
privKey
,
tmpKeyDestination
,
0640
)
checkCertificates
(
CertName
,
tmpCertificateDestination
,
tmpFullchainDestination
,
tmpCaDestination
,
tmpKeyDestination
,
Days
,
true
)
checkPrivkey
(
keyDestination
,
tmpCertificateDestination
,
opensslBinary
,
false
,
silent
)
//checkPrivkey(tmpKeyDestination, tmpCertificateDestination, true)
checkPrivkey
(
tmpKeyDestination
,
tmpCertificateDestination
,
opensslBinary
,
true
,
silent
)
// move certificates in place
moveFile
(
tmpCertificateDestination
,
certificateDestination
,
GroupID
,
0644
,
0755
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment