Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
ec200a9e
Unverified
Commit
ec200a9e
authored
Sep 09, 2016
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove duplicated ECDHE key handling
parent
4ab5a763
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
21 deletions
+3
-21
csr.go
pkg/util/cert/csr.go
+3
-21
No files found.
pkg/util/cert/csr.go
View file @
ec200a9e
...
@@ -17,15 +17,12 @@ limitations under the License.
...
@@ -17,15 +17,12 @@ limitations under the License.
package
cert
package
cert
import
(
import
(
"crypto/ecdsa"
"crypto/elliptic"
cryptorand
"crypto/rand"
cryptorand
"crypto/rand"
"crypto/rsa"
"crypto/rsa"
"crypto/x509"
"crypto/x509"
"crypto/x509/pkix"
"crypto/x509/pkix"
"encoding/pem"
"encoding/pem"
"errors"
"errors"
"fmt"
"net"
"net"
"k8s.io/kubernetes/pkg/apis/certificates"
"k8s.io/kubernetes/pkg/apis/certificates"
...
@@ -47,23 +44,11 @@ func ParseCSR(obj *certificates.CertificateSigningRequest) (*x509.CertificateReq
...
@@ -47,23 +44,11 @@ func ParseCSR(obj *certificates.CertificateSigningRequest) (*x509.CertificateReq
}
}
// MakeCSR generates a PEM-encoded CSR using the supplied private key, subject, and SANs.
// MakeCSR generates a PEM-encoded CSR using the supplied private key, subject, and SANs.
//
privateKey must be a *ecdsa.PrivateKey or *rsa.PrivateKey.
//
All key types that are implemented via crypto.Signer are supported (This includes *rsa.PrivateKey and *ecdsa.PrivateKey.)
func
MakeCSR
(
privateKey
interface
{},
subject
*
pkix
.
Name
,
dnsSANs
[]
string
,
ipSANs
[]
net
.
IP
)
(
csr
[]
byte
,
err
error
)
{
func
MakeCSR
(
privateKey
interface
{},
subject
*
pkix
.
Name
,
dnsSANs
[]
string
,
ipSANs
[]
net
.
IP
)
(
csr
[]
byte
,
err
error
)
{
// Customize the signature for RSA keys, depending on the key size
var
sigType
x509
.
SignatureAlgorithm
var
sigType
x509
.
SignatureAlgorithm
if
privateKey
,
ok
:=
privateKey
.
(
*
rsa
.
PrivateKey
);
ok
{
switch
privateKey
:=
privateKey
.
(
type
)
{
case
*
ecdsa
.
PrivateKey
:
switch
privateKey
.
Curve
{
case
elliptic
.
P224
(),
elliptic
.
P256
()
:
sigType
=
x509
.
ECDSAWithSHA256
case
elliptic
.
P384
()
:
sigType
=
x509
.
ECDSAWithSHA384
case
elliptic
.
P521
()
:
sigType
=
x509
.
ECDSAWithSHA512
default
:
return
nil
,
fmt
.
Errorf
(
"unknown elliptic curve: %v"
,
privateKey
.
Curve
)
}
case
*
rsa
.
PrivateKey
:
keySize
:=
privateKey
.
N
.
BitLen
()
keySize
:=
privateKey
.
N
.
BitLen
()
switch
{
switch
{
case
keySize
>=
4096
:
case
keySize
>=
4096
:
...
@@ -73,9 +58,6 @@ func MakeCSR(privateKey interface{}, subject *pkix.Name, dnsSANs []string, ipSAN
...
@@ -73,9 +58,6 @@ func MakeCSR(privateKey interface{}, subject *pkix.Name, dnsSANs []string, ipSAN
default
:
default
:
sigType
=
x509
.
SHA256WithRSA
sigType
=
x509
.
SHA256WithRSA
}
}
default
:
return
nil
,
fmt
.
Errorf
(
"unsupported key type: %T"
,
privateKey
)
}
}
template
:=
&
x509
.
CertificateRequest
{
template
:=
&
x509
.
CertificateRequest
{
...
...
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