GetDKIMKeyInternal returns the stored selector + private key bytes for a domain. The "Internal" suffix is load-bearing: this function does NOT scope by user — it takes a domain name and returns whoever owns that domain's signing key. ONLY call from server-internal codepaths where the domain has alre
(ctx context.Context, domain string)
| 585 | // treat this as "skip signing" and fall back to whatever the |
| 586 | // relay-level fallback does. |
| 587 | func (s *Store) GetDKIMKeyInternal(ctx context.Context, domain string) (string, []byte, error) { |
| 588 | norm := normalizeDomain(domain) |
| 589 | var selector string |
| 590 | var privKey []byte |
| 591 | err := s.pool.QueryRow(ctx, |
| 592 | `SELECT COALESCE(dkim_selector, ''), dkim_private_key FROM domains WHERE domain = $1`, |
| 593 | norm, |
| 594 | ).Scan(&selector, &privKey) |
| 595 | if errors.Is(err, pgx.ErrNoRows) { |
| 596 | return "", nil, nil |
| 597 | } |
| 598 | if err != nil { |
| 599 | return "", nil, fmt.Errorf("dkim key lookup: %w", err) |
| 600 | } |
| 601 | der, err := s.unsealDKIM(privKey, norm) |
| 602 | if err != nil { |
| 603 | return "", nil, fmt.Errorf("dkim key unseal: %w", err) |
| 604 | } |
| 605 | return selector, der, nil |
| 606 | } |
| 607 | |
| 608 | // --- Sender identity (decision 4 / Slice 4) --- |
| 609 | // |