Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dfss
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
7
Issues
7
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mpcs
dfss
Commits
2ed2387b
Commit
2ed2387b
authored
Jan 22, 2016
by
Loïck Bonniot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename package to autHority and fix lint
parent
c5015c9d
Pipeline
#152
failed with stage
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
39 deletions
+37
-39
.gitlab-ci.yml
.gitlab-ci.yml
+5
-3
dfssp/authority/rootCA.go
dfssp/authority/rootCA.go
+6
-3
dfssp/authority/rootCA_test.go
dfssp/authority/rootCA_test.go
+21
-28
dfssp/main.go
dfssp/main.go
+5
-5
No files found.
.gitlab-ci.yml
View file @
2ed2387b
...
...
@@ -16,9 +16,10 @@ Unit tests:
script
:
-
"
ln
-s
$(pwd)
$GOPATH/src/dfss"
-
"
./build/deps.sh"
-
"
go
test
-coverprofile
auth.part
-v
./auth"
-
"
go
test
-coverprofile
mgdb.part
-v
./mgdb"
-
"
go
test
-coverprofile
mails.part
-v
./mails"
-
"
go
test
-coverprofile
auth.part
-v
dfss/auth"
-
"
go
test
-coverprofile
mgdb.part
-v
dfss/mgdb"
-
"
go
test
-coverprofile
mails.part
-v
dfss/mails"
-
"
go
test
-coverprofile
authority.part
-v
dfss/dfssp/authority"
-
"
echo
'mode:
set'
*part
>
c.out"
-
"
grep
-h
-v
'mode:
set'
*part
>>
c.out"
-
"
go
tool
cover
-html=c.out
-o
coverage.html"
...
...
@@ -31,6 +32,7 @@ ARM tests:
-
"
./build/deps.sh"
-
"
go
test
-cover
-short
-v
./auth"
-
"
go
test
-cover
-short
-v
./mgdb"
-
"
go
test
-cover
-short
-v
./dfssp/..."
Code lint
:
stage
:
test
...
...
dfssp/autority/rootCA.go
→
dfssp/aut
h
ority/rootCA.go
View file @
2ed2387b
package
autority
package
aut
h
ority
import
(
"crypto/rsa"
...
...
@@ -12,10 +12,13 @@ import (
)
const
(
PkeyFileName
=
"dffsp_pkey.pem"
// PkeyFileName is the private key file default name
PkeyFileName
=
"dffsp_pkey.pem"
// RootCAFileName is the root certificate file default name
RootCAFileName
=
"dffsp_rootCA.pem"
)
// PlatformID contains platform private key and root certificate
type
PlatformID
struct
{
pkey
*
rsa
.
PrivateKey
rootCA
*
x509
.
Certificate
...
...
@@ -88,7 +91,7 @@ func Initialize(bits, days int, country, organization, unit, cn, path string) er
return
nil
}
//
Fetch
the platform's private rsa key and root certificate, and create a PlatformID accordingly.
//
Start fetches
the platform's private rsa key and root certificate, and create a PlatformID accordingly.
//
// The specified path should not end by a separator.
//
...
...
dfssp/autority/rootCA_test.go
→
dfssp/aut
h
ority/rootCA_test.go
View file @
2ed2387b
package
autority
package
aut
h
ority
import
(
"crypto/rsa"
...
...
@@ -50,13 +50,13 @@ func TestInitialize(t *testing.T) {
if
_
,
err
=
os
.
Stat
(
keyPath
);
os
.
IsNotExist
(
err
)
{
t
.
Fatal
(
"Private key file couldn't be found"
)
}
else
{
os
.
Remove
(
keyPath
)
_
=
os
.
Remove
(
keyPath
)
}
if
_
,
err
=
os
.
Stat
(
certPath
);
os
.
IsNotExist
(
err
)
{
t
.
Fatal
(
"Root certificate file couldn't be found"
)
}
else
{
os
.
Remove
(
certPath
)
_
=
os
.
Remove
(
certPath
)
}
}
...
...
@@ -71,29 +71,8 @@ func ExampleInitialize() {
fmt
.
Println
(
err
)
}
if
_
,
err
=
os
.
Stat
(
keyPath
);
os
.
IsNotExist
(
err
)
{
fmt
.
Println
(
"Private key file couldn't be found"
)
}
else
{
fmt
.
Println
(
"Private key file has been found"
)
err2
:=
os
.
Remove
(
keyPath
)
if
err2
!=
nil
{
fmt
.
Println
(
err2
)
}
else
{
fmt
.
Println
(
"Private key file has been deleted"
)
}
}
if
_
,
err
=
os
.
Stat
(
certPath
);
os
.
IsNotExist
(
err
)
{
fmt
.
Println
(
"Certificate file couldn't be found"
)
}
else
{
fmt
.
Println
(
"Certificate file has been found"
)
err2
:=
os
.
Remove
(
certPath
)
if
err2
!=
nil
{
fmt
.
Println
(
err2
)
}
else
{
fmt
.
Println
(
"Certificate file has been deleted"
)
}
}
checkFile
(
keyPath
,
"Private key"
)
checkFile
(
certPath
,
"Certificate"
)
// Output:
// Private key file has been found
...
...
@@ -102,6 +81,20 @@ func ExampleInitialize() {
// Certificate file has been deleted
}
func
checkFile
(
path
,
name
string
)
{
if
_
,
err
:=
os
.
Stat
(
path
);
os
.
IsNotExist
(
err
)
{
fmt
.
Println
(
name
+
" file couldn't be found"
)
}
else
{
fmt
.
Println
(
name
+
" file has been found"
)
err
=
os
.
Remove
(
path
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
}
else
{
fmt
.
Println
(
name
+
" file has been deleted"
)
}
}
}
func
TestStart
(
t
*
testing
.
T
)
{
path
:=
os
.
TempDir
()
keyPath
:=
filepath
.
Join
(
path
,
PkeyFileName
)
...
...
@@ -118,6 +111,6 @@ func TestStart(t *testing.T) {
t
.
Fatal
(
"Data was not recovered from saved files"
)
}
os
.
Remove
(
keyPath
)
os
.
Remove
(
certPath
)
_
=
os
.
Remove
(
keyPath
)
_
=
os
.
Remove
(
certPath
)
}
dfssp/main.go
View file @
2ed2387b
...
...
@@ -2,7 +2,7 @@ package main
import
(
"dfss"
"dfss/dfssp/autority"
"dfss/dfssp/aut
h
ority"
"flag"
"fmt"
"runtime"
...
...
@@ -12,14 +12,14 @@ var (
verbose
bool
path
,
country
,
org
,
unit
,
cn
string
keySize
,
validity
int
pid
*
autority
.
PlatformID
pid
*
aut
h
ority
.
PlatformID
)
func
init
()
{
flag
.
BoolVar
(
&
verbose
,
"v"
,
false
,
"Print verbose messages"
)
flag
.
StringVar
(
&
path
,
"path"
,
autority
.
GetHomeDir
(),
"Path for the platform's private key and root certificate"
)
flag
.
StringVar
(
&
path
,
"path"
,
aut
h
ority
.
GetHomeDir
(),
"Path for the platform's private key and root certificate"
)
flag
.
StringVar
(
&
country
,
"country"
,
"France"
,
"Country for the root certificate"
)
flag
.
StringVar
(
&
org
,
"org"
,
"DFSS"
,
"Organization for the root certificate"
)
flag
.
StringVar
(
&
unit
,
"unit"
,
"INSA Rennes"
,
"Organizational unit for the root certificate"
)
...
...
@@ -58,14 +58,14 @@ func main() {
case
"version"
:
fmt
.
Println
(
"v"
+
dfss
.
Version
,
runtime
.
GOOS
,
runtime
.
GOARCH
)
case
"init"
:
err
:=
autority
.
Initialize
(
keySize
,
validity
,
country
,
org
,
unit
,
cn
,
path
)
err
:=
aut
h
ority
.
Initialize
(
keySize
,
validity
,
country
,
org
,
unit
,
cn
,
path
)
if
err
!=
nil
{
fmt
.
Println
(
"An error occured during the initialization operation"
)
fmt
.
Println
(
err
)
panic
(
err
)
}
case
"start"
:
pid
,
err
:=
autority
.
Start
(
path
)
pid
,
err
:=
aut
h
ority
.
Start
(
path
)
if
err
!=
nil
{
fmt
.
Println
(
"An error occured during the start operation"
)
fmt
.
Println
(
err
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment