Disclaimer, this is half a tutorial, half a journal, I create this guide as I go. But rest asure, what I did was meant to run a reliable satellite, for production environment not a toy.
Not sure if you remember, in the early day, as a SNO, the flow when you create a new node have this very first step, fill in your email to get a authorize token, but nowaday:
You won’t find that step anymore, you wonder why?
As far as I understand, currently, there are (only?) 2 core services in satellite require certificate: satellite and jobq. Jobq originally was a built-in service within satellite, but later it was rewrite to be a dedicate service run outside of satellite. Why? Mostly because of performance. What does it do?
Jobq is a microservice that holds and prioritizes the list of storage segments waiting to be repaired. When the satellite detects that a segment has lost too many pieces (e.g., because storage nodes went offline), it pushes a repair job into jobq. Repair workers then pop jobs from the queue, always getting the most critical segments first — those with the lowest health score. Jobs that have already been attempted recently go into a separate retry queue and are held back until enough time has passed.
-Claude
The point is this: since it a separated, standalone service and could communicate with satellite over the internet, 2 issues arrive:
- Does communicate between jobq and satellite secure? Yes it is.
- Could a random satellite use your jobq? Now we get the crux of the problem.
Let me first show you my script for generating certificate:
#!/bin/bash
if [ "$(id -u)" -ne 0 ]; then
echo -e "\033[1;31mERROR: must be running as root, exit code 1\033[0m" >&2
exit 1
fi
if [ "$SCRIPT_DIR" = "" ]; then
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
fi
if [ "$ID_DIR" = "" ]; then
ID_DIR=$SCRIPT_DIR/id
fi
OS_ID=$(grep ^ID= /etc/os-release | cut -d= -f2 | tr -d '"')
if [[ ! -f "$SCRIPT_DIR/identity" ]]; then
echo "identity binary file not exist in $SCRIPT_DIR, exit code 2"
exit 2
fi
# 1. GEN ROOT CA
if [[ ! -d "$SCRIPT_DIR/root-ca" ]]; then
echo "-- GENERATING ROOT CA --"
mkdir -p "$SCRIPT_DIR/root-ca"
$SCRIPT_DIR/identity certificate-authority create \
--ca.cert-path="$SCRIPT_DIR/root-ca/root-ca.cert" \
--ca.key-path="$SCRIPT_DIR/root-ca/root-ca.key"
else
echo "-- ROOT CA ALREADY GENERATED -- SKIPPING --"
fi
# 2. GEN SATELLITE ID
if [[ ! -d "$ID_DIR/satellite" ]]; then
echo "-- GENERATING SAT CERT --"
$SCRIPT_DIR/identity create satellite \
--config-dir="$SCRIPT_DIR" \
--identity-dir="$ID_DIR" \
--parent-cert-path="$SCRIPT_DIR/root-ca/root-ca.cert" \
--parent-key-path="$SCRIPT_DIR/root-ca/root-ca.key"
else
echo '-- SATELLITE ID DIR ALREADY GENERATED -- SKIPPING --'
fi
# 3. GEN JOBQ ID
if [[ ! -d "$ID_DIR/jobq" ]]; then
echo "-- GENERATING JOBQ CERT --"
$SCRIPT_DIR/identity create jobq \
--config-dir="$SCRIPT_DIR" \
--identity-dir="$ID_DIR" \
--parent-cert-path="$SCRIPT_DIR/root-ca/root-ca.cert" \
--parent-key-path="$SCRIPT_DIR/root-ca/root-ca.key"
else
echo '-- JOBQ ID DIR ALREADY GENERATED -- SKIPPING --'
fi
# 4. GEN AUDITOR ID
if [[ ! -d "$ID_DIR/auditor" ]]; then
echo "-- GENERATING AUDITOR CERT --"
$SCRIPT_DIR/identity create auditor \
--config-dir="$SCRIPT_DIR" \
--identity-dir="$ID_DIR" \
--parent-cert-path="$SCRIPT_DIR/root-ca/root-ca.cert" \
--parent-key-path="$SCRIPT_DIR/root-ca/root-ca.key"
else
echo '-- AUDITOR ID DIR ALREADY GENERATED -- SKIPPING --'
fi
The important part here is your root ca, if you create certificate this way, it create a chain of certificates (you CAN create satellite identity without a root ca).
So why is that SNO don’t need authorize token anymore?
I think because of this commit storagenode/peer: don't require CA whitelist any longer · storj/storj@1d63395 · GitHub, but I’m a bit confused, in that commit, they say they gonna eventually disable it on satellite entirely.
But then how do it stop a random satellite connect to a random jobq if jobq expose over the internet? As I understand, ca-whitelist is last battalion to prevent this situation – unless of course, jobq must be on the same infrastructure with satellite, no expose to the internet, but then we are locking ourself to a single vendor with a point of failure. Am I mis-understand something? Any developer explanation would be really appreciated.
For now my script is working as intended, see you on part 4.
Hi @Alexey, could you help me merge part 2 and 1, I’ll edit it after you merge, thank you very much!
IMPORTANT NOTICE
P/s: After writing tutorial after 10 parts, I’ve a new insight, maybe instead of using multiple keys, you can just use a single key pair (still need root-ca, so that 2) for all services, if you see future guide only use satellite service instead of dedicate named keys: api, admin, core, auditor, … You know why. See [Tutorial] Run your own satellite (part 3) - Generate certificates - #8 by kocoten1992