If we look on wikipedia there is the following version of the Hahn-Banach theorem :
Let $X$ be a real topological vector space and choose $A$, $B$ convex non-empty disjoint subsets of $X$ such that $A$ is open then $A$ and $B$ are separated by a (closed) hyperplane. Explicitly, this means that there exists a continuous linear map $f : X \to \mathbb R$ and $s \in \mathbb R$ such that $f(a) < s \leq f(b)$ for all $a \in A$, $b \in B$. If both $A$ and $B$ are open then the right-hand side may be taken strict as well.
I'm wondering about the case where $A$ is relatively open instead, that is if $\mathrm{ri} A = A$ with $\mathrm{ri} A = \{ x\in A: \mathrm{span} (A-x)=\mathrm{cone}(A-x) \}$ the relative interior (I think it can be equivalently defined as $\{ x: \exists \varepsilon>0, (x+\varepsilon B_1)\cap \mathrm{aff}(A) \subseteq A\}$ in the case of a Banach space with unit open ball $B_1$, $\mathrm{aff}A$ is the affine hull of $A$, that is the intersection of all affine sets that contains $A$). In the case of $X=\mathbb R^n$, The proof is done (with some adaptation) in chapter 11 of Rockafellar's Convex Analysis (in particular Theorem 11.3 can show it). This proof however relies heavily on finite dimensionality of $X$, since we basically build a space of dimension $0$ and then augment the dimension to $n-1$. I'm wondering if there is some literature in a more general setting.
Seeing @daw 's answer, it is not true in general, I am however wondering about when $B$ is closed. I guess something like :
Let $A$ and $B$ be two closed convex subsets of $X$ such that $\mathrm{ri} A\cap \mathrm{ri} B=\emptyset$, then there exists a continuous linear functional $f:X\to\mathbb R$ such that $\sup f(A) \leq \inf f(B)$ and $\forall x\in\mathrm{ri}(A)$, $f(x)< \inf f(B)$ as well as $\forall y\in\mathrm{ri}(B)$, $\sup f(A)<f(y)$
Here is a counter-example: Let $B$ be a dense subspace of the normed space $X$, $A=\{x\}$ with $x\not\in B$. Then $ri A= A$ but both sets cannot be separated as desired.