Skip to main content
Version: V1.4.0

Primary and standby network security and authentication

Primary and standby seekdb instances synchronize and call services over RPC. By default, connections are not authenticated and traffic is plaintext: any process on the network could impersonate a node or eavesdrop. If you need stronger security, enable TLS. Both sides must present certificates signed by the same CA, which gives you:

  • Mutual authentication: The server checks the client certificate and the client checks the server certificate, which mitigates man-in-the-middle attacks and unauthorized nodes.
  • Encryption: All RPC traffic is encrypted. After the TLS handshake, peers derive a symmetric key and all gRPC messages use it; nothing sensitive is sent in plaintext.

Architecture​

Primary node                     Standby node
┌─────────────────┐ ┌─────────────────┐
│ ObGrpcServer │ │ ObGrpcClient │
│ (SslServer │◄────mTLS────►│ (SslCredentials│
│ Credentials) │ │ ) │
│ wallet/ │ │ wallet/ │
│ ├─ ca.pem │ │ ├─ ca.pem │ ← same CA
│ ├─ cert.pem │ │ ├─ cert.pem │
│ └─ key.pem │ │ └─ key.pem │
└─────────────────┘ └─────────────────┘

Each node keeps three files under the wallet/ directory in the process working directory:

FileContents
wallet/ca.pemCA root certificate (public key) used to verify the peer
wallet/cert.pemNode certificate (public key), with SAN for this host's IP
wallet/key.pemNode private key

Deployment​

Prerequisites​

  • Certificate files are prepared.

  • TLS must be enabled on both primary and standby. It is controlled by enable_rpc_tls.

    ParameterTypeDefaultHow it appliesDescription
    enable_rpc_tlsBOOLFalseAfter restartWhether to enable mutual TLS for RPC.

Procedure​

The following uses primary IP 10.0.0.1 and standby IP 10.0.0.2. Run all commands on any machine with openssl, then distribute the files.

  1. Generate the CA

    # CA private key (4096-bit)
    openssl genrsa -out ca.key 4096

    # Self-signed CA certificate, 365 days
    openssl req -x509 -new -nodes \
    -key ca.key \
    -sha256 -days 365 \
    -subj "/O=OceanBase/CN=OceanBase-CA" \
    -out ca.pem

    Store ca.key securely; it is used to sign node certificates.

  2. Generate the primary certificate (IP: 10.0.0.1)

    PRIMARY_IP="10.0.0.1"

    # Node private key
    openssl genrsa -out primary_key.pem 2048

    # CSR
    openssl req -new \
    -key primary_key.pem \
    -subj "/O=OceanBase/CN=${PRIMARY_IP}" \
    -out primary.csr

    # Sign certificate; SAN includes the primary IP
    echo "subjectAltName=IP:${PRIMARY_IP}" > primary_san.ext
    openssl x509 -req \
    -in primary.csr \
    -CA ca.pem -CAkey ca.key \
    -CAcreateserial \
    -extfile primary_san.ext \
    -days 365 -sha256 \
    -out primary_cert.pem

    # Verify SAN
    openssl x509 -in primary_cert.pem -noout -ext subjectAltName
    # Expected: IP Address:10.0.0.1

    Keep primary_key.pem, the private key of the primary node, secure.

  3. Generate the standby certificate (IP: 10.0.0.2)

    STANDBY_IP="10.0.0.2"

    openssl genrsa -out standby_key.pem 2048

    openssl req -new \
    -key standby_key.pem \
    -subj "/O=OceanBase/CN=${STANDBY_IP}" \
    -out standby.csr

    echo "subjectAltName=IP:${STANDBY_IP}" > standby_san.ext
    openssl x509 -req \
    -in standby.csr \
    -CA ca.pem -CAkey ca.key \
    -CAcreateserial \
    -extfile standby_san.ext \
    -days 365 -sha256 \
    -out standby_cert.pem

    openssl x509 -in standby_cert.pem -noout -ext subjectAltName
    # Expected: IP Address:10.0.0.2
  4. Copy files to each node

    • Primary ($PRIMARY/wallet/)

      mkdir -p $PRIMARY/wallet
      cp ca.pem $PRIMARY/wallet/ca.pem
      cp primary_cert.pem $PRIMARY/wallet/cert.pem
      cp primary_key.pem $PRIMARY/wallet/key.pem
      chmod 600 $PRIMARY/wallet/key.pem
      chmod 644 $PRIMARY/wallet/ca.pem
      chmod 644 $PRIMARY/wallet/cert.pem
    • Standby ($STANDBY/wallet/)

      mkdir -p $STANDBY/wallet
      cp ca.pem $STANDBY/wallet/ca.pem
      cp standby_cert.pem $STANDBY/wallet/cert.pem
      cp standby_key.pem $STANDBY/wallet/key.pem
      chmod 600 $STANDBY/wallet/key.pem
      chmod 644 $STANDBY/wallet/ca.pem
      chmod 644 $STANDBY/wallet/cert.pem
  5. Enable RPC TLS separately on the primary and standby, and then restart both instances:

    ALTER SYSTEM SET enable_rpc_tls = TRUE;

    enable_rpc_tls is a static configuration item. Restart the instances only after the certificate files are in place. Existing RPC connections do not switch to TLS merely because this configuration item was changed.

Verification​

  1. Confirm TLS is active

    Connect to the primary and standby, and use the public view to inspect node certificate expiration times:

    SELECT SVR_IP, SVR_PORT, RPC_CERT_EXPIRE_TIME
    FROM V$OB_SERVER_STAT;

    RPC_CERT_EXPIRE_TIME is the expiration time of wallet/cert.pem. It is NULL when no RPC certificate is loaded. Also execute SHOW PARAMETERS LIKE 'enable_rpc_tls'; and verify that the current value is True.

  2. Test the handshake with openssl s_client

    # Whether the server requires a client cert (mTLS)
    # Without a client cert, handshake should fail
    openssl s_client -connect <ip>:<rpc_port> \
    -CAfile wallet/ca.pem \
    -tls1_3 2>&1 | tail -5
    # Under TLS 1.3, server rejection often shows: unexpected eof while reading

    # With client cert, handshake should succeed
    openssl s_client -connect <ip>:<rpc_port> \
    -CAfile wallet/ca.pem \
    -cert wallet/cert.pem \
    -key wallet/key.pem \
    -tls1_3 2>&1 | grep "Verify return code"
    # Expected: Verify return code: 0 (ok)

Certificate rotation​

Set certificate validity according to your organization's security policy and complete rotation before expiration to prevent an expired certificate from interrupting synchronization between the primary and standby.

When a certificate is about to expire, replace cert.pem and key.pem in each node's wallet/ directory. If the CA is unchanged, you do not need to replace ca.pem. After replacement, restart the primary and standby in a maintenance window and verify synchronization again.