Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nexus
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
Package 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
flg_projects
nexus_vdi
nexus
Commits
9c3f1276
Commit
9c3f1276
authored
1 month ago
by
Florent Gluck
Browse files
Options
Downloads
Patches
Plain Diff
Started removing code dealing with embedded CA certificate as it is not needed anymore
parent
5a70a771
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Makefile
+11
-16
11 additions, 16 deletions
Makefile
client/defaults/Defaults.go
+0
-22
0 additions, 22 deletions
client/defaults/Defaults.go
client/nexush/nexush.go
+6
-39
6 additions, 39 deletions
client/nexush/nexush.go
with
17 additions
and
77 deletions
Makefile
+
11
−
16
View file @
9c3f1276
...
...
@@ -262,13 +262,14 @@ help_client:
@
echo
" xbuild_client Cross-build
$(
BIN
)
for Linux, Windows, Darwin (OSX)"
@
echo
" Require the BIN variable which specifies which client to"
@
echo
" cross-build: nexush or nexus-cli"
@
echo
" Require SERVER
and CERT
(see below)"
@
echo
" build_nexush Build nexush for Linux/amd64; require
the
SERVER
variable
"
@
echo
"
and CERT
(see below)"
@
echo
" Require SERVER
environment variable
(see below)"
@
echo
" build_nexush Build nexush for Linux/amd64; require SERVER
environment
"
@
echo
"
variable
(see below)"
@
echo
" build_nexus-cli Build nexus-cli for Linux/amd64; same as above"
@
echo
" build_nexus-exam Build nexus-exam for Linux/amd64; require CERT, SERVER"
@
echo
" EXAM_USER and EXAM_PWD. The last two define credentials"
@
echo
" for the user used by nexus-exam to connect to nexus server"
@
echo
" build_nexus-exam Build nexus-exam for Linux/amd64; require SERVER, EXAM_USER"
@
echo
" and EXAM_PWD environment variables. The last two define"
@
echo
" credentials for the user used by nexus-exam to connect to"
@
echo
" nexus server"
@
echo
" clean_clients Delete all generated client binaries"
@
echo
""
@
echo
"┌──────────────────────────────────────────────────────────────────────────────┐"
...
...
@@ -282,21 +283,15 @@ help_client:
@
echo
"│ VALIDATION tests │"
@
echo
"└──────────────────────────────────────────────────────────────────────────────┘"
@
echo
" tests Run validation tests using nexus-cli"
@
echo
" Require LOGIN variable.
Example:
"
@
echo
" Require LOGIN variable."
@
echo
""
@
echo
"────────────────────────────────────────────────────────────────────────────────"
@
echo
" CERT: path to public CA certificate file (
$(
CA_CERT_FILE
)
)."
@
echo
" SERVER: server ip address and port, separated by a colon,"
@
echo
" for instance: SERVER=127.0.0.1:1077"
copy_resources_client
:
@
mkdir
-p
$(
RESOURCES_DIR_CLIENT
)
@
echo
-n
"
$(
SERVER
)
"
>
$(
RESOURCES_DIR_CLIENT
)
/server
ifdef
CERT
@
cp
$(
CERT
)
$(
RESOURCES_DIR_CLIENT
)
/
$(
CA_CERT_FILE
)
else
@
echo
-n
""
>
$(
RESOURCES_DIR_CLIENT
)
/
$(
CA_CERT_FILE
)
endif
xbuild_client
:
check_bin_var check_server_var check_cert_var copy_resources_client $(SRC_CLIENT)/nexush $(SRC_CLIENT)/nexus-cli
@
echo
"[Cross-building
$(
BIN
)
into
$(
BUILD_DIR
)
directory]"
...
...
@@ -318,15 +313,15 @@ xbuild_client: check_bin_var check_server_var check_cert_var copy_resources_clie
done
\
done
build_nexush
:
check_server_var
check_cert_var
copy_resources_client $(BUILD_DIR) $(SRC_CLIENT)/nexush
build_nexush
:
check_server_var copy_resources_client $(BUILD_DIR) $(SRC_CLIENT)/nexush
@
echo
"[Building nexush into
$(
BUILD_DIR
)
directory]"
@
cd
$(
SRC_CLIENT
)
/nexush
&&
go build
$(
BUILD_FLAGS
)
$(
BUILD_CLIENT_FLAGS
)
&&
mv
$(
NEXUSH_BINARY
)
$(
BUILD_DIR_ABS
)
build_nexus-cli
:
check_server_var
check_cert_var
copy_resources_client $(BUILD_DIR) $(SRC_CLIENT)/nexus-cli
build_nexus-cli
:
check_server_var copy_resources_client $(BUILD_DIR) $(SRC_CLIENT)/nexus-cli
@
echo
"[Building nexus-cli into
$(
BUILD_DIR
)
directory]"
@
cd
$(
SRC_CLIENT
)
/nexus-cli
&&
go build
$(
BUILD_FLAGS
)
$(
BUILD_CLIENT_FLAGS
)
&&
mv
$(
NEXUSCLI_BINARY
)
$(
BUILD_DIR_ABS
)
build_nexus-exam
:
check_server_var
check_cert_var
check_nexus_exam_vars copy_resources_client $(BUILD_DIR) $(SRC_CLIENT)/nexus-exam
build_nexus-exam
:
check_server_var check_nexus_exam_vars copy_resources_client $(BUILD_DIR) $(SRC_CLIENT)/nexus-exam
@
echo
"[Building nexus-exam into
$(
BUILD_DIR
)
directory]"
@
echo
-n
'
$(
value EXAM_USER
)
'
>
$(
NEXUS_EXAM_USER_CREDS_FILE
)
@
echo
-n
'
$(
value EXAM_PWD
)
'
>
$(
NEXUS_EXAM_PWD_CREDS_FILE
)
...
...
This diff is collapsed.
Click to expand it.
client/defaults/Defaults.go
+
0
−
22
View file @
9c3f1276
package
defaults
import
(
"os"
_
"embed"
)
var
(
//go:embed resources/ca-cert.pem
nexusPubCert
string
//go:embed resources/server
NexusServer
string
)
func
CreateCert
()
(
string
,
error
)
{
// No embedded certificate
if
nexusPubCert
==
""
{
return
""
,
nil
}
else
{
f
,
err
:=
os
.
CreateTemp
(
""
,
"nexus-client-"
)
if
err
!=
nil
{
return
""
,
err
}
if
_
,
err
:=
f
.
Write
([]
byte
(
nexusPubCert
));
err
!=
nil
{
return
""
,
err
}
defer
f
.
Close
()
return
f
.
Name
(),
nil
}
}
This diff is collapsed.
Click to expand it.
client/nexush/nexush.go
+
6
−
39
View file @
9c3f1276
...
...
@@ -27,7 +27,6 @@ import (
"gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/client/version"
"gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/common/buildversion"
"gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/common/utils"
"github.com/peterh/liner"
"golang.org/x/term"
...
...
@@ -111,44 +110,12 @@ func run() int {
var
err
error
// necessary for certPath below to be ref as the same variable
certPath
,
found
:=
os
.
LookupEnv
(
g
.
ENV_NEXUS_CERT
)
if
!
found
{
certPath
,
err
=
defaults
.
CreateCert
()
if
err
!=
nil
{
u
.
PrintlnErr
(
"Failed creating certificate from embedded certificate!"
)
return
1
}
// No embedded certificate, exit with a information message.
if
certPath
==
""
{
u
.
PrintlnErr
(
"Environment variable
\"
"
+
g
.
ENV_NEXUS_CERT
+
"
\"
must be set!"
)
u
.
PrintlnErr
(
"It specifies the path to the public certificate required for encrypted communications (TLS) with the nexus server."
)
u
.
PrintlnErr
(
"Example: export "
+
g
.
ENV_NEXUS_CERT
+
"=ca-cert.pem"
)
return
1
}
defer
os
.
Remove
(
certPath
)
// This thread acts as a signal handler for SIGINT or SIGTERM.
// When one of these signals is received, the temporary certificate file is deleted.
// Without this "handler", the temporary certificate file wouldn't be deleted.
go
func
(
certFile
string
)
{
u
.
WaitForSignals
()
os
.
Remove
(
certFile
)
restoreTerm
()
os
.
Exit
(
1
)
}(
certPath
)
}
else
{
// As above, this thread acts as a signal handler for SIGINT or SIGTERM.
go
func
()
{
u
.
WaitForSignals
()
restoreTerm
()
os
.
Exit
(
1
)
}()
}
if
!
utils
.
FileExists
(
certPath
)
{
u
.
PrintlnErr
(
"Failed reading certificate
\"
"
+
certPath
+
"
\"
!"
)
return
1
}
// This thread acts as a signal handler for SIGINT or SIGTERM.
go
func
()
{
u
.
WaitForSignals
()
restoreTerm
()
os
.
Exit
(
1
)
}()
nc
:=
nc
.
New
(
serverEnvVar
)
...
...
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