Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
0d8d0ba5
Commit
0d8d0ba5
authored
Jan 16, 2016
by
Xidorn Quan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
letsencrypt: Fix perm of user key
parent
8655ea67
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletion
+16
-1
caddy/letsencrypt/crypto.go
caddy/letsencrypt/crypto.go
+1
-0
caddy/letsencrypt/crypto_test.go
caddy/letsencrypt/crypto_test.go
+15
-1
No files found.
caddy/letsencrypt/crypto.go
View file @
0d8d0ba5
...
...
@@ -25,6 +25,7 @@ func saveRSAPrivateKey(key *rsa.PrivateKey, file string) error {
if
err
!=
nil
{
return
err
}
keyOut
.
Chmod
(
0600
)
defer
keyOut
.
Close
()
return
pem
.
Encode
(
keyOut
,
&
pemKey
)
}
caddy/letsencrypt/crypto_test.go
View file @
0d8d0ba5
...
...
@@ -6,6 +6,7 @@ import (
"crypto/rsa"
"crypto/x509"
"os"
"runtime"
"testing"
)
...
...
@@ -28,13 +29,26 @@ func TestSaveAndLoadRSAPrivateKey(t *testing.T) {
t
.
Fatal
(
"error saving private key:"
,
err
)
}
// it doesn't make sense to test file permission on windows
if
runtime
.
GOOS
!=
"windows"
{
// get info of the key file
info
,
err
:=
os
.
Stat
(
keyFile
)
if
err
!=
nil
{
t
.
Fatal
(
"error stating private key:"
,
err
)
}
// verify permission of key file is correct
if
info
.
Mode
()
.
Perm
()
!=
0600
{
t
.
Error
(
"Expected key file to have permission 0600, but it wasn't"
)
}
}
// test load
loadedKey
,
err
:=
loadRSAPrivateKey
(
keyFile
)
if
err
!=
nil
{
t
.
Error
(
"error loading private key:"
,
err
)
}
// very loaded key is correct
// ver
if
y loaded key is correct
if
!
rsaPrivateKeysSame
(
privateKey
,
loadedKey
)
{
t
.
Error
(
"Expected key bytes to be the same, but they weren't"
)
}
...
...
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