Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p-quic-transport
Commits
2737d8c0
Commit
2737d8c0
authored
Aug 05, 2018
by
Marten Seemann
Browse files
generate certificates that are valid for 180 days
parent
9d8055d4
Changes
1
Show whitespace changes
Inline
Side-by-side
crypto.go
View file @
2737d8c0
...
...
@@ -18,6 +18,8 @@ import (
// mint certificate selection is broken.
const
hostname
=
"quic.ipfs"
const
certValidityPeriod
=
180
*
24
*
time
.
Hour
func
generateConfig
(
privKey
ic
.
PrivKey
)
(
*
tls
.
Config
,
error
)
{
key
,
hostCert
,
err
:=
keyToCertificate
(
privKey
)
if
err
!=
nil
{
...
...
@@ -35,7 +37,7 @@ func generateConfig(privKey ic.PrivKey) (*tls.Config, error) {
DNSNames
:
[]
string
{
hostname
},
SerialNumber
:
big
.
NewInt
(
1
),
NotBefore
:
time
.
Now
()
.
Add
(
-
24
*
time
.
Hour
),
NotAfter
:
time
.
Now
()
.
Add
(
30
*
24
*
time
.
Hour
),
NotAfter
:
time
.
Now
()
.
Add
(
certValidityPeriod
),
}
certDER
,
err
:=
x509
.
CreateCertificate
(
rand
.
Reader
,
certTemplate
,
hostCert
,
ephemeralKey
.
Public
(),
key
)
if
err
!=
nil
{
...
...
@@ -80,7 +82,7 @@ func keyToCertificate(sk ic.PrivKey) (interface{}, *x509.Certificate, error) {
tmpl
:=
&
x509
.
Certificate
{
SerialNumber
:
sn
,
NotBefore
:
time
.
Now
()
.
Add
(
-
24
*
time
.
Hour
),
NotAfter
:
time
.
Now
()
.
Add
(
30
*
24
*
time
.
Hour
),
NotAfter
:
time
.
Now
()
.
Add
(
certValidityPeriod
),
IsCA
:
true
,
BasicConstraintsValid
:
true
,
}
...
...
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