@@ -355,18 +355,6 @@ func TryLoadPrivatePublicKeyFromDisk(pkiPath, name string) (crypto.PrivateKey, c
355
355
}
356
356
}
357
357
358
- // TryLoadCSRFromDisk tries to load the CSR from the disk
359
- func TryLoadCSRFromDisk (pkiPath , name string ) (* x509.CertificateRequest , error ) {
360
- csrPath := pathForCSR (pkiPath , name )
361
-
362
- csr , err := CertificateRequestFromFile (csrPath )
363
- if err != nil {
364
- return nil , errors .Wrapf (err , "could not load the CSR %s" , csrPath )
365
- }
366
-
367
- return csr , nil
368
- }
369
-
370
358
// PathsForCertAndKey returns the paths for the certificate and key given the path and basename.
371
359
func PathsForCertAndKey (pkiPath , name string ) (string , string ) {
372
360
return pathForCert (pkiPath , name ), pathForKey (pkiPath , name )
@@ -507,34 +495,6 @@ func EncodeCSRPEM(csr *x509.CertificateRequest) []byte {
507
495
return pem .EncodeToMemory (& block )
508
496
}
509
497
510
- func parseCSRPEM (pemCSR []byte ) (* x509.CertificateRequest , error ) {
511
- block , _ := pem .Decode (pemCSR )
512
- if block == nil {
513
- return nil , errors .New ("data doesn't contain a valid certificate request" )
514
- }
515
-
516
- if block .Type != certutil .CertificateRequestBlockType {
517
- return nil , errors .Errorf ("expected block type %q, but PEM had type %q" , certutil .CertificateRequestBlockType , block .Type )
518
- }
519
-
520
- return x509 .ParseCertificateRequest (block .Bytes )
521
- }
522
-
523
- // CertificateRequestFromFile returns the CertificateRequest from a given PEM-encoded file.
524
- // Returns an error if the file could not be read or if the CSR could not be parsed.
525
- func CertificateRequestFromFile (file string ) (* x509.CertificateRequest , error ) {
526
- pemBlock , err := os .ReadFile (file )
527
- if err != nil {
528
- return nil , errors .Wrap (err , "failed to read file" )
529
- }
530
-
531
- csr , err := parseCSRPEM (pemBlock )
532
- if err != nil {
533
- return nil , errors .Wrapf (err , "error reading certificate request file %s" , file )
534
- }
535
- return csr , nil
536
- }
537
-
538
498
// NewCSR creates a new CSR
539
499
func NewCSR (cfg CertConfig , key crypto.Signer ) (* x509.CertificateRequest , error ) {
540
500
RemoveDuplicateAltNames (& cfg .AltNames )
0 commit comments