redirect.go 1.1 KB
Newer Older
Heiko Reese's avatar
 
Heiko Reese committed
1
2
3
package websearch

import (
Heiko Reese's avatar
../..    
Heiko Reese committed
4
5
	"errors"
	"math/big"
Heiko Reese's avatar
 
Heiko Reese committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
)

var (
	serialG2Start  big.Int
	serialG1Cutoff big.Int
)

func init() {
	serialG2Start.SetString("8926168349745120614054526923", 10)
	serialG1Cutoff.SetString("99000000000000000000000000000", 10) // TODO: anpassen sobald bekannt

}

const (
	getcertTempl     = "https://pki.pca.dfn.de/%s/cgi-bin/pub/pki?cmd=send_email_cert&type=email&dataType=CERTIFICATE&key=%s"
	installcertTempl = "https://pki.pca.dfn.de/%s/cgi-bin/pub/pki?cmd=getcert&type=CERTIFICATE&key=%s"
	testCertURL      = getcertTempl
)

func BuildCertificateLink(serial string) (string, error) {
	// convert to integer
	var sernum big.Int
	_, ok := sernum.SetString(serial, 10)
	if !ok {
		return "", errors.New("Unable to convert serial number to bigint")
	}
	// alte CA (kurze nummern, serial kleiner als erstes g2)
	if len(serial) == 8 || len(serial) == 14 || sernum.Cmp(&serialG2Start) < 1 {
		return kitcag1, nil
	}
	// neue CA (seriennummer größer als letztes g1)
	if sernum.Cmp(&serialG1Cutoff) == 1 {
		return kitcag2, nil
	}

Heiko Reese's avatar
../..    
Heiko Reese committed
41
	// TODO: memdb befragen
Heiko Reese's avatar
 
Heiko Reese committed
42
43
44

	return "", errors.New("both callouts failed")
}