_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q31000 | CountRegistrationsByIP | train | func (ssa *SQLStorageAuthority) CountRegistrationsByIP(ctx context.Context, ip net.IP, earliest time.Time, latest time.Time) (int, error) {
var count int64
err := ssa.dbMap.WithContext(ctx).SelectOne(
&count,
`SELECT COUNT(1) FROM registrations
WHERE
initialIP = :ip AND
:earliest < createdAt AND
creat... | go | {
"resource": ""
} |
q31001 | CountCertificatesByNames | train | func (ssa *SQLStorageAuthority) CountCertificatesByNames(ctx context.Context, domains []string, earliest, latest time.Time) ([]*sapb.CountByNames_MapElement, error) {
work := make(chan string, len(domains))
type result struct {
err error
count int
domain string
}
results := make(chan result, len(domains))... | go | {
"resource": ""
} |
q31002 | countCertificatesByNameImpl | train | func (ssa *SQLStorageAuthority) countCertificatesByNameImpl(
db dbSelector,
domain string,
earliest,
latest time.Time,
) (int, error) {
return ssa.countCertificates(db, domain, earliest, latest, countCertificatesSelect)
} | go | {
"resource": ""
} |
q31003 | countCertificatesByExactNameImpl | train | func (ssa *SQLStorageAuthority) countCertificatesByExactNameImpl(
db dbSelector,
domain string,
earliest,
latest time.Time,
) (int, error) {
return ssa.countCertificates(db, domain, earliest, latest, countCertificatesExactSelect)
} | go | {
"resource": ""
} |
q31004 | countCertificates | train | func (ssa *SQLStorageAuthority) countCertificates(db dbSelector, domain string, earliest, latest time.Time, query string) (int, error) {
var serials []string
_, err := db.Select(
&serials,
query,
map[string]interface{}{
"reversedDomain": ReverseName(domain),
"earliest": earliest,
"latest": ... | go | {
"resource": ""
} |
q31005 | GetCertificate | train | func (ssa *SQLStorageAuthority) GetCertificate(ctx context.Context, serial string) (core.Certificate, error) {
if !core.ValidSerial(serial) {
err := fmt.Errorf("Invalid certificate serial %s", serial)
return core.Certificate{}, err
}
cert, err := SelectCertificate(ssa.dbMap.WithContext(ctx), "WHERE serial = ?",... | go | {
"resource": ""
} |
q31006 | GetCertificateStatus | train | func (ssa *SQLStorageAuthority) GetCertificateStatus(ctx context.Context, serial string) (core.CertificateStatus, error) {
if !core.ValidSerial(serial) {
err := fmt.Errorf("Invalid certificate serial %s", serial)
return core.CertificateStatus{}, err
}
var status core.CertificateStatus
statusObj, err := ssa.dbM... | go | {
"resource": ""
} |
q31007 | NewRegistration | train | func (ssa *SQLStorageAuthority) NewRegistration(ctx context.Context, reg core.Registration) (core.Registration, error) {
reg.CreatedAt = ssa.clk.Now()
rm, err := registrationToModel(®)
if err != nil {
return reg, err
}
err = ssa.dbMap.WithContext(ctx).Insert(rm)
if err != nil {
return reg, err
}
return m... | go | {
"resource": ""
} |
q31008 | UpdateRegistration | train | func (ssa *SQLStorageAuthority) UpdateRegistration(ctx context.Context, reg core.Registration) error {
const query = "WHERE id = ?"
model, err := selectRegistration(ssa.dbMap.WithContext(ctx), query, reg.ID)
if err == sql.ErrNoRows {
return berrors.NotFoundError("registration with ID '%d' not found", reg.ID)
}
... | go | {
"resource": ""
} |
q31009 | NewPendingAuthorization | train | func (ssa *SQLStorageAuthority) NewPendingAuthorization(ctx context.Context, authz core.Authorization) (core.Authorization, error) {
var output core.Authorization
tx, err := ssa.dbMap.Begin()
if err != nil {
return output, err
}
txWithCtx := tx.WithContext(ctx)
// Create a random ID and check that it doesn't ... | go | {
"resource": ""
} |
q31010 | GetPendingAuthorization | train | func (ssa *SQLStorageAuthority) GetPendingAuthorization(
ctx context.Context,
req *sapb.GetPendingAuthorizationRequest,
) (*core.Authorization, error) {
identifierJSON, err := json.Marshal(core.AcmeIdentifier{
Type: core.IdentifierType(*req.IdentifierType),
Value: *req.IdentifierValue,
})
if err != nil {
re... | go | {
"resource": ""
} |
q31011 | FinalizeAuthorization | train | func (ssa *SQLStorageAuthority) FinalizeAuthorization(ctx context.Context, authz core.Authorization) error {
tx, err := ssa.dbMap.Begin()
if err != nil {
return err
}
txWithCtx := tx.WithContext(ctx)
// Check that a pending authz exists
if !existingPending(txWithCtx, authz.ID) {
err = berrors.NotFoundError("... | go | {
"resource": ""
} |
q31012 | RevokeAuthorizationsByDomain | train | func (ssa *SQLStorageAuthority) RevokeAuthorizationsByDomain(ctx context.Context, ident core.AcmeIdentifier) (int64, int64, error) {
identifierJSON, err := json.Marshal(ident)
if err != nil {
return 0, 0, err
}
identifier := string(identifierJSON)
results := []int64{0, 0}
now := ssa.clk.Now()
for i, table := ... | go | {
"resource": ""
} |
q31013 | RevokeAuthorizationsByDomain2 | train | func (ssa *SQLStorageAuthority) RevokeAuthorizationsByDomain2(ctx context.Context, req *sapb.RevokeAuthorizationsByDomainRequest) (*corepb.Empty, error) {
finalRevoked, pendingRevoked, err := ssa.RevokeAuthorizationsByDomain(
ctx,
core.AcmeIdentifier{
Type: core.IdentifierDNS,
Value: *req.Domain,
})
if e... | go | {
"resource": ""
} |
q31014 | AddCertificate | train | func (ssa *SQLStorageAuthority) AddCertificate(
ctx context.Context,
certDER []byte,
regID int64,
ocspResponse []byte,
issued *time.Time) (string, error) {
parsedCertificate, err := x509.ParseCertificate(certDER)
if err != nil {
return "", err
}
digest := core.Fingerprint256(certDER)
serial := core.SerialTo... | go | {
"resource": ""
} |
q31015 | CountPendingAuthorizations | train | func (ssa *SQLStorageAuthority) CountPendingAuthorizations(ctx context.Context, regID int64) (count int, err error) {
err = ssa.dbMap.WithContext(ctx).SelectOne(&count,
`SELECT count(1) FROM pendingAuthorizations
WHERE registrationID = :regID AND
expires > :now AND
status = :pending`,
map[string]interface{}{... | go | {
"resource": ""
} |
q31016 | CountInvalidAuthorizations | train | func (ssa *SQLStorageAuthority) CountInvalidAuthorizations(
ctx context.Context,
req *sapb.CountInvalidAuthorizationsRequest,
) (count *sapb.Count, err error) {
identifier := core.AcmeIdentifier{
Type: core.IdentifierDNS,
Value: *req.Hostname,
}
idJSON, err := json.Marshal(identifier)
if err != nil {
retu... | go | {
"resource": ""
} |
q31017 | addOrderFQDNSet | train | func addOrderFQDNSet(
db dbInserter,
names []string,
orderID int64,
regID int64,
expires time.Time) error {
return db.Insert(&orderFQDNSet{
SetHash: hashNames(names),
OrderID: orderID,
RegistrationID: regID,
Expires: expires,
})
} | go | {
"resource": ""
} |
q31018 | deleteOrderFQDNSet | train | func deleteOrderFQDNSet(
db dbExecer,
orderID int64) error {
result, err := db.Exec(`
DELETE FROM orderFqdnSets
WHERE orderID = ?`,
orderID)
if err != nil {
return err
}
rowsDeleted, err := result.RowsAffected()
if err != nil {
return err
}
// We always expect there to be an order FQDN set row for ... | go | {
"resource": ""
} |
q31019 | CountFQDNSets | train | func (ssa *SQLStorageAuthority) CountFQDNSets(ctx context.Context, window time.Duration, names []string) (int64, error) {
var count int64
err := ssa.dbMap.WithContext(ctx).SelectOne(
&count,
`SELECT COUNT(1) FROM fqdnSets
WHERE setHash = ?
AND issued > ?`,
hashNames(names),
ssa.clk.Now().Add(-window),
)
... | go | {
"resource": ""
} |
q31020 | getFQDNSetsBySerials | train | func (ssa *SQLStorageAuthority) getFQDNSetsBySerials(
db dbSelector,
serials []string,
) ([]setHash, error) {
var fqdnSets []setHash
// It is unexpected that this function would be called with no serials
if len(serials) == 0 {
err := fmt.Errorf("getFQDNSetsBySerials called with no serials")
ssa.log.AuditErr(e... | go | {
"resource": ""
} |
q31021 | FQDNSetExists | train | func (ssa *SQLStorageAuthority) FQDNSetExists(ctx context.Context, names []string) (bool, error) {
exists, err := ssa.checkFQDNSetExists(
ssa.dbMap.WithContext(ctx).SelectOne,
names)
if err != nil {
return false, err
}
return exists, nil
} | go | {
"resource": ""
} |
q31022 | checkFQDNSetExists | train | func (ssa *SQLStorageAuthority) checkFQDNSetExists(selector oneSelectorFunc, names []string) (bool, error) {
var count int64
err := selector(
&count,
`SELECT COUNT(1) FROM fqdnSets
WHERE setHash = ?
LIMIT 1`,
hashNames(names),
)
return count > 0, err
} | go | {
"resource": ""
} |
q31023 | DeactivateRegistration | train | func (ssa *SQLStorageAuthority) DeactivateRegistration(ctx context.Context, id int64) error {
_, err := ssa.dbMap.WithContext(ctx).Exec(
"UPDATE registrations SET status = ? WHERE status = ? AND id = ?",
string(core.StatusDeactivated),
string(core.StatusValid),
id,
)
return err
} | go | {
"resource": ""
} |
q31024 | DeactivateAuthorization | train | func (ssa *SQLStorageAuthority) DeactivateAuthorization(ctx context.Context, id string) error {
tx, err := ssa.dbMap.Begin()
if err != nil {
return err
}
txWithCtx := tx.WithContext(ctx)
if existingPending(txWithCtx, id) {
authzObj, err := txWithCtx.Get(&pendingauthzModel{}, id)
if err != nil {
return Ro... | go | {
"resource": ""
} |
q31025 | DeactivateAuthorization2 | train | func (ssa *SQLStorageAuthority) DeactivateAuthorization2(ctx context.Context, req *sapb.AuthorizationID2) (*corepb.Empty, error) {
_, err := ssa.dbMap.Exec(
`UPDATE authz2 SET status = :deactivated WHERE id = :id and status IN (:valid,:pending)`,
map[string]interface{}{
"deactivated": statusUint(core.StatusDeac... | go | {
"resource": ""
} |
q31026 | NewOrder | train | func (ssa *SQLStorageAuthority) NewOrder(ctx context.Context, req *corepb.Order) (*corepb.Order, error) {
order := &orderModel{
RegistrationID: *req.RegistrationID,
Expires: time.Unix(0, *req.Expires),
Created: ssa.clk.Now(),
}
tx, err := ssa.dbMap.Begin()
if err != nil {
return nil, err
}
... | go | {
"resource": ""
} |
q31027 | SetOrderError | train | func (ssa *SQLStorageAuthority) SetOrderError(ctx context.Context, order *corepb.Order) error {
tx, err := ssa.dbMap.Begin()
if err != nil {
return err
}
txWithCtx := tx.WithContext(ctx)
om, err := orderToModel(order)
if err != nil {
return Rollback(tx, err)
}
result, err := txWithCtx.Exec(`
UPDATE orde... | go | {
"resource": ""
} |
q31028 | GetOrder | train | func (ssa *SQLStorageAuthority) GetOrder(ctx context.Context, req *sapb.OrderRequest) (*corepb.Order, error) {
omObj, err := ssa.dbMap.WithContext(ctx).Get(orderModel{}, *req.Id)
if err == sql.ErrNoRows || omObj == nil {
return nil, berrors.NotFoundError("no order found for ID %d", *req.Id)
}
if err != nil {
re... | go | {
"resource": ""
} |
q31029 | GetValidOrderAuthorizations | train | func (ssa *SQLStorageAuthority) GetValidOrderAuthorizations(
ctx context.Context,
req *sapb.GetValidOrderAuthorizationsRequest) (map[string]*core.Authorization, error) {
now := ssa.clk.Now()
// Select the full authorization data for all *valid, unexpired*
// authorizations that are owned by the correct account ID ... | go | {
"resource": ""
} |
q31030 | GetAuthorizations | train | func (ssa *SQLStorageAuthority) GetAuthorizations(
ctx context.Context,
req *sapb.GetAuthorizationsRequest) (*sapb.Authorizations, error) {
authzMap, err := ssa.getAuthorizations(
ctx,
authorizationTable,
string(core.StatusValid),
*req.RegistrationID,
req.Domains,
time.Unix(0, *req.Now),
*req.RequireV2... | go | {
"resource": ""
} |
q31031 | AddPendingAuthorizations | train | func (ssa *SQLStorageAuthority) AddPendingAuthorizations(ctx context.Context, req *sapb.AddPendingAuthorizationsRequest) (*sapb.AuthorizationIDs, error) {
ids := []string{}
for _, authPB := range req.Authz {
authz, err := bgrpc.PBToAuthz(authPB)
if err != nil {
return nil, err
}
result, err := ssa.NewPendi... | go | {
"resource": ""
} |
q31032 | NewAuthorizations2 | train | func (ssa *SQLStorageAuthority) NewAuthorizations2(ctx context.Context, req *sapb.AddPendingAuthorizationsRequest) (*sapb.Authorization2IDs, error) {
ids := &sapb.Authorization2IDs{}
for _, authz := range req.Authz {
if *authz.Status != string(core.StatusPending) {
return nil, berrors.InternalServerError("author... | go | {
"resource": ""
} |
q31033 | GetAuthorization2 | train | func (ssa *SQLStorageAuthority) GetAuthorization2(ctx context.Context, id *sapb.AuthorizationID2) (*corepb.Authorization, error) {
obj, err := ssa.dbMap.Get(authz2Model{}, *id.Id)
if err != nil {
return nil, err
}
if obj == nil {
return nil, berrors.NotFoundError("authorization %d not found", *id.Id)
}
return... | go | {
"resource": ""
} |
q31034 | authz2ModelMapToPB | train | func authz2ModelMapToPB(m map[string]authz2Model) (*sapb.Authorizations, error) {
resp := &sapb.Authorizations{}
for k, v := range m {
// Make a copy of k because it will be reassigned with each loop.
kCopy := k
authzPB, err := modelToAuthzPB(&v)
if err != nil {
return nil, err
}
resp.Authz = append(re... | go | {
"resource": ""
} |
q31035 | FinalizeAuthorization2 | train | func (ssa *SQLStorageAuthority) FinalizeAuthorization2(ctx context.Context, req *sapb.FinalizeAuthorizationRequest) error {
if *req.Status != string(core.StatusValid) && *req.Status != string(core.StatusInvalid) {
return berrors.InternalServerError("authorization must have status valid or invalid")
}
query := `UPD... | go | {
"resource": ""
} |
q31036 | RevokeCertificate | train | func (ssa *SQLStorageAuthority) RevokeCertificate(ctx context.Context, req *sapb.RevokeCertificateRequest) error {
tx, err := ssa.dbMap.Begin()
if err != nil {
return err
}
txWithCtx := tx.WithContext(ctx)
status, err := SelectCertificateStatus(
txWithCtx,
"WHERE serial = ? AND status != ?",
*req.Serial,
... | go | {
"resource": ""
} |
q31037 | GetPendingAuthorization2 | train | func (ssa *SQLStorageAuthority) GetPendingAuthorization2(ctx context.Context, req *sapb.GetPendingAuthorizationRequest) (*corepb.Authorization, error) {
var am authz2Model
err := ssa.dbMap.WithContext(ctx).SelectOne(
&am,
fmt.Sprintf(`SELECT %s FROM authz2 WHERE
registrationID = :regID AND
identifierValue =... | go | {
"resource": ""
} |
q31038 | CountPendingAuthorizations2 | train | func (ssa *SQLStorageAuthority) CountPendingAuthorizations2(ctx context.Context, req *sapb.RegistrationID) (*sapb.Count, error) {
var count int64
err := ssa.dbMap.WithContext(ctx).SelectOne(&count,
`SELECT COUNT(1) FROM authz2 WHERE
registrationID = :regID AND
expires > :expires AND
status = :status`,
map[s... | go | {
"resource": ""
} |
q31039 | GetValidOrderAuthorizations2 | train | func (ssa *SQLStorageAuthority) GetValidOrderAuthorizations2(ctx context.Context, req *sapb.GetValidOrderAuthorizationsRequest) (*sapb.Authorizations, error) {
var ams []authz2Model
_, err := ssa.dbMap.WithContext(ctx).Select(
&ams,
fmt.Sprintf(`SELECT %s FROM authz2
LEFT JOIN orderToAuthz2 ON authz2.ID = orde... | go | {
"resource": ""
} |
q31040 | CountInvalidAuthorizations2 | train | func (ssa *SQLStorageAuthority) CountInvalidAuthorizations2(ctx context.Context, req *sapb.CountInvalidAuthorizationsRequest) (*sapb.Count, error) {
var count int64
err := ssa.dbMap.WithContext(ctx).SelectOne(
&count,
`SELECT COUNT(1) FROM authz2 WHERE
registrationID = :regID AND
identifierValue = :ident AND
... | go | {
"resource": ""
} |
q31041 | GetValidAuthorizations2 | train | func (ssa *SQLStorageAuthority) GetValidAuthorizations2(ctx context.Context, req *sapb.GetValidAuthorizationsRequest) (*sapb.Authorizations, error) {
var authzModels []authz2Model
params := []interface{}{
*req.RegistrationID,
time.Unix(0, *req.Now),
statusUint(core.StatusValid),
}
qmarks := make([]string, len... | go | {
"resource": ""
} |
q31042 | replaceInvalidUTF8 | train | func replaceInvalidUTF8(input []byte) string {
var b strings.Builder
// Ranging over a string in Go produces runes. When the range keyword
// encounters an invalid UTF-8 encoding, it returns REPLACEMENT CHARACTER.
for _, v := range string(input) {
b.WriteRune(v)
}
return b.String()
} | go | {
"resource": ""
} |
q31043 | Len | train | func (c *logCache) Len() int {
c.RLock()
defer c.RUnlock()
return len(c.logs)
} | go | {
"resource": ""
} |
q31044 | LogURIs | train | func (c *logCache) LogURIs() []string {
c.RLock()
defer c.RUnlock()
var uris []string
for _, l := range c.logs {
uris = append(uris, l.uri)
}
return uris
} | go | {
"resource": ""
} |
q31045 | NewLog | train | func NewLog(uri, b64PK string, logger blog.Logger) (*Log, error) {
url, err := url.Parse(uri)
if err != nil {
return nil, err
}
url.Path = strings.TrimSuffix(url.Path, "/")
pemPK := fmt.Sprintf("-----BEGIN PUBLIC KEY-----\n%s\n-----END PUBLIC KEY-----",
b64PK)
opts := jsonclient.Options{
Logger: logAdap... | go | {
"resource": ""
} |
q31046 | New | train | func New(
bundle []ct.ASN1Cert,
logger blog.Logger,
stats metrics.Scope,
) *Impl {
return &Impl{
issuerBundle: bundle,
ctLogsCache: logCache{
logs: make(map[string]*Log),
},
log: logger,
metrics: initMetrics(stats),
}
} | go | {
"resource": ""
} |
q31047 | ProbeLogs | train | func (pub *Impl) ProbeLogs() {
wg := new(sync.WaitGroup)
for _, log := range pub.ctLogsCache.LogURIs() {
wg.Add(1)
go func(uri string) {
defer wg.Done()
c := http.Client{
Timeout: time.Minute*2 + time.Second*30,
}
url, err := url.Parse(uri)
if err != nil {
pub.log.Errf("failed to parse log ... | go | {
"resource": ""
} |
q31048 | VerifyCSR | train | func VerifyCSR(csr *x509.CertificateRequest, maxNames int, keyPolicy *goodkey.KeyPolicy, pa core.PolicyAuthority, forceCNFromSAN bool, regID int64) error {
normalizeCSR(csr, forceCNFromSAN)
key, ok := csr.PublicKey.(crypto.PublicKey)
if !ok {
return invalidPubKey
}
if err := keyPolicy.GoodKey(key); err != nil {
... | go | {
"resource": ""
} |
q31049 | normalizeCSR | train | func normalizeCSR(csr *x509.CertificateRequest, forceCNFromSAN bool) {
if forceCNFromSAN && csr.Subject.CommonName == "" {
if len(csr.DNSNames) > 0 {
csr.Subject.CommonName = csr.DNSNames[0]
}
} else if csr.Subject.CommonName != "" {
csr.DNSNames = append(csr.DNSNames, csr.Subject.CommonName)
}
csr.Subject... | go | {
"resource": ""
} |
q31050 | NewKeyPolicy | train | func NewKeyPolicy(weakKeyFile string) (KeyPolicy, error) {
kp := KeyPolicy{
AllowRSA: true,
AllowECDSANISTP256: true,
AllowECDSANISTP384: true,
}
if weakKeyFile != "" {
keyList, err := LoadWeakRSASuffixes(weakKeyFile)
if err != nil {
return KeyPolicy{}, err
}
kp.weakRSAList = keyList
}
r... | go | {
"resource": ""
} |
q31051 | checkSmallPrimes | train | func checkSmallPrimes(i *big.Int) bool {
smallPrimesSingleton.Do(func() {
for _, prime := range smallPrimeInts {
smallPrimes = append(smallPrimes, big.NewInt(prime))
}
})
for _, prime := range smallPrimes {
var result big.Int
result.Mod(i, prime)
if result.Sign() == 0 {
return true
}
}
return f... | go | {
"resource": ""
} |
q31052 | NewMockScope | train | func NewMockScope(ctrl *gomock.Controller) *MockScope {
mock := &MockScope{ctrl: ctrl}
mock.recorder = &MockScopeMockRecorder{mock}
return mock
} | go | {
"resource": ""
} |
q31053 | MustRegister | train | func (m *MockScope) MustRegister(arg0 ...prometheus.Collector) {
m.ctrl.T.Helper()
varargs := []interface{}{}
for _, a := range arg0 {
varargs = append(varargs, a)
}
m.ctrl.Call(m, "MustRegister", varargs...)
} | go | {
"resource": ""
} |
q31054 | NewScope | train | func (m *MockScope) NewScope(arg0 ...string) metrics.Scope {
m.ctrl.T.Helper()
varargs := []interface{}{}
for _, a := range arg0 {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "NewScope", varargs...)
ret0, _ := ret[0].(metrics.Scope)
return ret0
} | go | {
"resource": ""
} |
q31055 | TimingDuration | train | func (m *MockScope) TimingDuration(arg0 string, arg1 time.Duration) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "TimingDuration", arg0, arg1)
} | go | {
"resource": ""
} |
q31056 | baseDomain | train | func baseDomain(name string) string {
eTLDPlusOne, err := publicsuffix.Domain(name)
if err != nil {
// publicsuffix.Domain will return an error if the input name is itself a
// public suffix. In that case we use the input name as the key for rate
// limiting. Since all of its subdomains will have separate keys ... | go | {
"resource": ""
} |
q31057 | addCertificatesPerName | train | func (ssa *SQLStorageAuthority) addCertificatesPerName(
ctx context.Context,
db dbSelectExecer,
names []string,
timeToTheHour time.Time,
) error {
if !features.Enabled(features.FasterRateLimit) {
return nil
}
// De-duplicate the base domains.
baseDomainsMap := make(map[string]bool)
var qmarks []string
var v... | go | {
"resource": ""
} |
q31058 | getKey | train | func getKey(ctx pkcs11helpers.PKCtx, session pkcs11.SessionHandle, label string, idStr string) (*x509Signer, error) {
id, err := hex.DecodeString(idStr)
if err != nil {
return nil, err
}
// Retrieve the private key handle that will later be used for the certificate
// signing operation
privateHandle, err := fi... | go | {
"resource": ""
} |
q31059 | makeTemplate | train | func makeTemplate(ctx pkcs11helpers.PKCtx, profile *CertProfile, pubKey []byte, session pkcs11.SessionHandle) (*x509.Certificate, error) {
dateLayout := "2006-01-02 15:04:05"
notBefore, err := time.Parse(dateLayout, profile.NotBefore)
if err != nil {
return nil, err
}
notAfter, err := time.Parse(dateLayout, prof... | go | {
"resource": ""
} |
q31060 | generateRevokedResponse | train | func (updater *OCSPUpdater) generateRevokedResponse(ctx context.Context, status core.CertificateStatus) (*core.CertificateStatus, []string, error) {
cert, err := updater.sac.GetCertificate(ctx, status.Serial)
if err != nil {
return nil, nil, err
}
signRequest := core.OCSPSigningRequest{
CertDER: cert.DER,
... | go | {
"resource": ""
} |
q31061 | markExpired | train | func (updater *OCSPUpdater) markExpired(status core.CertificateStatus) error {
_, err := updater.dbMap.Exec(
`UPDATE certificateStatus
SET isExpired = TRUE
WHERE serial = ?`,
status.Serial,
)
return err
} | go | {
"resource": ""
} |
q31062 | InitDBMetrics | train | func InitDBMetrics(dbMap *gorp.DbMap, scope metrics.Scope) {
// Create a dbMetrics instance and register prometheus metrics
dbm := newDbMetrics(dbMap, scope)
// Start the metric reporting goroutine to update the metrics periodically.
go dbm.reportDBMetrics()
} | go | {
"resource": ""
} |
q31063 | newDbMetrics | train | func newDbMetrics(dbMap *gorp.DbMap, scope metrics.Scope) *dbMetrics {
maxOpenConns := prometheus.NewGauge(prometheus.GaugeOpts{
Name: "db_max_open_connections",
Help: "Maximum number of DB connections allowed.",
})
scope.MustRegister(maxOpenConns)
openConns := prometheus.NewGauge(prometheus.GaugeOpts{
Name:... | go | {
"resource": ""
} |
q31064 | updateFrom | train | func (dbm *dbMetrics) updateFrom(dbStats sql.DBStats) {
dbm.maxOpenConnections.Set(float64(dbStats.MaxOpenConnections))
dbm.openConnections.Set(float64(dbStats.OpenConnections))
dbm.inUse.Set(float64(dbStats.InUse))
dbm.idle.Set(float64(dbStats.InUse))
dbm.waitCount.Set(float64(dbStats.WaitCount))
dbm.waitDuratio... | go | {
"resource": ""
} |
q31065 | reportDBMetrics | train | func (dbm *dbMetrics) reportDBMetrics() {
for {
stats := dbm.dbMap.Db.Stats()
dbm.updateFrom(stats)
time.Sleep(1 * time.Second)
}
} | go | {
"resource": ""
} |
q31066 | unwrapError | train | func unwrapError(err error, md metadata.MD) error {
if err == nil {
return nil
}
if errTypeStrs, ok := md["errortype"]; ok {
unwrappedErr := grpc.ErrorDesc(err)
if len(errTypeStrs) != 1 {
return berrors.InternalServerError(
"multiple errorType metadata, wrapped error %q",
unwrappedErr,
)
}
er... | go | {
"resource": ""
} |
q31067 | New | train | func New(
server,
port,
username,
password string,
rootCAs *x509.CertPool,
from mail.Address,
logger blog.Logger,
stats metrics.Scope,
reconnectBase time.Duration,
reconnectMax time.Duration) *MailerImpl {
return &MailerImpl{
dialer: &dialerImpl{
username: username,
password: password,
server: s... | go | {
"resource": ""
} |
q31068 | NewDryRun | train | func NewDryRun(from mail.Address, logger blog.Logger) *MailerImpl {
stats := metrics.NewNoopScope()
return &MailerImpl{
dialer: dryRunClient{logger},
from: from,
clk: clock.Default(),
csprgSource: realSource{},
stats: stats,
}
} | go | {
"resource": ""
} |
q31069 | Connect | train | func (m *MailerImpl) Connect() error {
client, err := m.dialer.Dial()
if err != nil {
return err
}
m.client = client
return nil
} | go | {
"resource": ""
} |
q31070 | SendMail | train | func (m *MailerImpl) SendMail(to []string, subject, msg string) error {
m.stats.Inc("SendMail.Attempts", 1)
for {
err := m.sendOne(to, subject, msg)
if err == nil {
// If the error is nil, we sent the mail without issue. nice!
break
} else if err == io.EOF {
// If the error is an EOF, we should try to... | go | {
"resource": ""
} |
q31071 | Rollback | train | func Rollback(tx *gorp.Transaction, err error) error {
if txErr := tx.Rollback(); txErr != nil {
return &RollbackError{
Err: err,
RollbackErr: txErr,
}
}
return err
} | go | {
"resource": ""
} |
q31072 | noteSignError | train | func (ca *CertificateAuthorityImpl) noteSignError(err error) {
if err != nil {
if _, ok := err.(*pkcs11.Error); ok {
ca.stats.Inc(metricHSMError, 1)
} else if cfErr, ok := err.(*cferr.Error); ok {
ca.stats.Inc(fmt.Sprintf("%s.%d", metricSigningError, cfErr.ErrorCode), 1)
}
}
return
} | go | {
"resource": ""
} |
q31073 | GenerateOCSP | train | func (ca *CertificateAuthorityImpl) GenerateOCSP(ctx context.Context, xferObj core.OCSPSigningRequest) ([]byte, error) {
cert, err := x509.ParseCertificate(xferObj.CertDER)
if err != nil {
ca.log.AuditErr(err.Error())
return nil, err
}
signRequest := ocsp.SignRequest{
Certificate: cert,
Status: xferOb... | go | {
"resource": ""
} |
q31074 | IssueCertificateForPrecertificate | train | func (ca *CertificateAuthorityImpl) IssueCertificateForPrecertificate(ctx context.Context, req *caPB.IssueCertificateForPrecertificateRequest) (core.Certificate, error) {
emptyCert := core.Certificate{}
precert, err := x509.ParseCertificate(req.DER)
if err != nil {
return emptyCert, err
}
var scts []ct.SignedCer... | go | {
"resource": ""
} |
q31075 | OrphanIntegrationLoop | train | func (ca *CertificateAuthorityImpl) OrphanIntegrationLoop() {
for {
if err := ca.integrateOrphan(); err != nil {
if err == goque.ErrEmpty {
time.Sleep(time.Minute)
continue
}
ca.log.AuditErrf("failed to integrate orphaned certs: %s", err)
}
}
} | go | {
"resource": ""
} |
q31076 | integrateOrphan | train | func (ca *CertificateAuthorityImpl) integrateOrphan() error {
item, err := ca.orphanQueue.Peek()
if err != nil {
if err == goque.ErrEmpty {
return goque.ErrEmpty
}
return fmt.Errorf("failed to peek into orphan queue: %s", err)
}
var orphan orphanedCert
if err = item.ToObject(&orphan); err != nil {
retur... | go | {
"resource": ""
} |
q31077 | enforceJWSAuthType | train | func (wfe *WebFrontEndImpl) enforceJWSAuthType(
jws *jose.JSONWebSignature,
expectedAuthType jwsAuthType) *probs.ProblemDetails {
// Check the auth type for the provided JWS
authType, prob := checkJWSAuthType(jws)
if prob != nil {
wfe.stats.joseErrorCount.With(prometheus.Labels{"type": "JWSAuthTypeInvalid"}).Inc... | go | {
"resource": ""
} |
q31078 | validPOSTURL | train | func (wfe *WebFrontEndImpl) validPOSTURL(
request *http.Request,
jws *jose.JSONWebSignature) *probs.ProblemDetails {
// validPOSTURL is called after parseJWS() which defends against the incorrect
// number of signatures.
header := jws.Signatures[0].Header
extraHeaders := header.ExtraHeaders
// Check that there i... | go | {
"resource": ""
} |
q31079 | matchJWSURLs | train | func (wfe *WebFrontEndImpl) matchJWSURLs(outer, inner *jose.JSONWebSignature) *probs.ProblemDetails {
// Verify that the outer JWS has a non-empty URL header. This is strictly
// defensive since the expectation is that endpoints using `matchJWSURLs`
// have received at least one of their JWS from calling validPOSTFo... | go | {
"resource": ""
} |
q31080 | parseJWSRequest | train | func (wfe *WebFrontEndImpl) parseJWSRequest(request *http.Request) (*jose.JSONWebSignature, *probs.ProblemDetails) {
// Verify that the POST request has the expected headers
if prob := wfe.validPOSTRequest(request); prob != nil {
return nil, prob
}
// Read the POST request body's bytes. validPOSTRequest has alre... | go | {
"resource": ""
} |
q31081 | extractJWK | train | func (wfe *WebFrontEndImpl) extractJWK(jws *jose.JSONWebSignature) (*jose.JSONWebKey, *probs.ProblemDetails) {
// extractJWK expects the request to be using an embedded JWK auth type and
// to not contain the mutually exclusive KeyID.
if prob := wfe.enforceJWSAuthType(jws, embeddedJWK); prob != nil {
return nil, p... | go | {
"resource": ""
} |
q31082 | acctIDFromURL | train | func (wfe *WebFrontEndImpl) acctIDFromURL(acctURL string, request *http.Request) (int64, *probs.ProblemDetails) {
// For normal ACME v2 accounts we expect the account URL has a prefix composed
// of the Host header and the acctPath.
expectedURLPrefix := web.RelativeEndpoint(request, acctPath)
// Process the acctUR... | go | {
"resource": ""
} |
q31083 | lookupJWK | train | func (wfe *WebFrontEndImpl) lookupJWK(
jws *jose.JSONWebSignature,
ctx context.Context,
request *http.Request,
logEvent *web.RequestEvent) (*jose.JSONWebKey, *core.Registration, *probs.ProblemDetails) {
// We expect the request to be using an embedded Key ID auth type and to not
// contain the mutually exclusive ... | go | {
"resource": ""
} |
q31084 | validPOSTForAccount | train | func (wfe *WebFrontEndImpl) validPOSTForAccount(
request *http.Request,
ctx context.Context,
logEvent *web.RequestEvent) ([]byte, *jose.JSONWebSignature, *core.Registration, *probs.ProblemDetails) {
// Parse the JWS from the POST request
jws, prob := wfe.parseJWSRequest(request)
if prob != nil {
return nil, nil... | go | {
"resource": ""
} |
q31085 | validSelfAuthenticatedPOST | train | func (wfe *WebFrontEndImpl) validSelfAuthenticatedPOST(
request *http.Request,
logEvent *web.RequestEvent) ([]byte, *jose.JSONWebKey, *probs.ProblemDetails) {
// Parse the JWS from the POST request
jws, prob := wfe.parseJWSRequest(request)
if prob != nil {
return nil, nil, prob
}
// Extract and validate the em... | go | {
"resource": ""
} |
q31086 | NewDNSClientImpl | train | func NewDNSClientImpl(
readTimeout time.Duration,
servers []string,
stats metrics.Scope,
clk clock.Clock,
maxTries int,
) *DNSClientImpl {
stats = stats.NewScope("DNS")
// TODO(jmhodges): make constructor use an Option func pattern
dnsClient := new(dns.Client)
// Set timeout for underlying net.Conn
dnsClient... | go | {
"resource": ""
} |
q31087 | LookupTXT | train | func (dnsClient *DNSClientImpl) LookupTXT(ctx context.Context, hostname string) ([]string, []string, error) {
var txt []string
dnsType := dns.TypeTXT
r, err := dnsClient.exchangeOne(ctx, hostname, dnsType)
if err != nil {
return nil, nil, &DNSError{dnsType, hostname, err, -1}
}
if r.Rcode != dns.RcodeSuccess {
... | go | {
"resource": ""
} |
q31088 | LookupCAA | train | func (dnsClient *DNSClientImpl) LookupCAA(ctx context.Context, hostname string) ([]*dns.CAA, error) {
dnsType := dns.TypeCAA
r, err := dnsClient.exchangeOne(ctx, hostname, dnsType)
if err != nil {
return nil, &DNSError{dnsType, hostname, err, -1}
}
if r.Rcode == dns.RcodeServerFailure {
return nil, &DNSError{... | go | {
"resource": ""
} |
q31089 | LookupMX | train | func (dnsClient *DNSClientImpl) LookupMX(ctx context.Context, hostname string) ([]string, error) {
dnsType := dns.TypeMX
r, err := dnsClient.exchangeOne(ctx, hostname, dnsType)
if err != nil {
return nil, &DNSError{dnsType, hostname, err, -1}
}
if r.Rcode != dns.RcodeSuccess {
return nil, &DNSError{dnsType, ho... | go | {
"resource": ""
} |
q31090 | rsaArgs | train | func rsaArgs(label string, modulusLen, exponent uint, keyID []byte) generateArgs {
// Encode as unpadded big endian encoded byte slice
expSlice := big.NewInt(int64(exponent)).Bytes()
log.Printf("\tEncoded public exponent (%d) as: %0X\n", exponent, expSlice)
return generateArgs{
mechanism: []*pkcs11.Mechanism{
... | go | {
"resource": ""
} |
q31091 | rsaPub | train | func rsaPub(ctx pkcs11helpers.PKCtx, session pkcs11.SessionHandle, object pkcs11.ObjectHandle, modulusLen, exponent uint) (*rsa.PublicKey, error) {
pubKey, err := pkcs11helpers.GetRSAPublicKey(ctx, session, object)
if err != nil {
return nil, err
}
if pubKey.E != int(exponent) {
return nil, errors.New("returned... | go | {
"resource": ""
} |
q31092 | rsaVerify | train | func rsaVerify(ctx pkcs11helpers.PKCtx, session pkcs11.SessionHandle, object pkcs11.ObjectHandle, pub *rsa.PublicKey) error {
nonce, err := getRandomBytes(ctx, session)
if err != nil {
return fmt.Errorf("Failed to retrieve nonce: %s", err)
}
log.Printf("\tConstructed nonce: %d (%X)\n", big.NewInt(0).SetBytes(nonc... | go | {
"resource": ""
} |
q31093 | rsaGenerate | train | func rsaGenerate(ctx pkcs11helpers.PKCtx, session pkcs11.SessionHandle, label string, modulusLen, pubExponent uint) (*rsa.PublicKey, error) {
keyID := make([]byte, 4)
_, err := rand.Read(keyID)
if err != nil {
return nil, err
}
log.Printf("Generating RSA key with %d bit modulus and public exponent %d and ID %x\n... | go | {
"resource": ""
} |
q31094 | New | train | func New(log *syslog.Writer, stdoutLogLevel int, syslogLogLevel int) (Logger, error) {
if log == nil {
return nil, errors.New("Attempted to use a nil System Logger.")
}
return &impl{
&bothWriter{log, stdoutLogLevel, syslogLogLevel, clock.Default()},
}, nil
} | go | {
"resource": ""
} |
q31095 | initialize | train | func initialize() {
// defaultPriority is never used because we always use specific priority-based
// logging methods.
const defaultPriority = syslog.LOG_INFO | syslog.LOG_LOCAL0
syslogger, err := syslog.Dial("", "", defaultPriority, "test")
if err != nil {
panic(err)
}
logger, err := New(syslogger, int(syslog... | go | {
"resource": ""
} |
q31096 | Set | train | func Set(logger Logger) (err error) {
if _Singleton.log != nil {
err = errors.New("You may not call Set after it has already been implicitly or explicitly set.")
_Singleton.log.Warning(err.Error())
} else {
_Singleton.log = logger
}
return
} | go | {
"resource": ""
} |
q31097 | Get | train | func Get() Logger {
_Singleton.once.Do(func() {
if _Singleton.log == nil {
initialize()
}
})
return _Singleton.log
} | go | {
"resource": ""
} |
q31098 | logAtLevel | train | func (w *bothWriter) logAtLevel(level syslog.Priority, msg string) {
var prefix string
var err error
const red = "\033[31m\033[1m"
const yellow = "\033[33m"
switch syslogAllowed := int(level) <= w.syslogLevel; level {
case syslog.LOG_ERR:
if syslogAllowed {
err = w.Err(msg)
}
prefix = red + "E"
case s... | go | {
"resource": ""
} |
q31099 | caller | train | func caller(level int) string {
_, file, line, _ := runtime.Caller(level)
splits := strings.Split(file, "/")
filename := splits[len(splits)-1]
return fmt.Sprintf("%s:%d:", filename, line)
} | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.