*Claim:* Suppose that $G$ is a connected bounded open set in $\mathbb R^n$ such that for every $x\in\partial G$, there exist $r>0$ and a half-space $S$ such that $x\in\partial S$ and $G\cap B(x,r)\subset S$. Then $G$ is convex. *Proof:* Step 1. Suppose that $f:G\to \mathbb R$ is a continuous function such that for every $x\in G$, there exists $r>0$ and a linear function $L_x$ satisfying $L_x(x)=f(x)$ and $f(y)<L_x(y)$ for all $y\ne x$ with $|y-x|<r$. Then $f$ is concave in the sense that if $a,b\in G$ and the whole interval $[a,b]$ is contained in $G$, then $f(ta+(1-t)b)\ge tf(a)+(1-t)f(b)$ for $t\in[0,1]$. Proof: Suppose not. Then $\min_t[f(ta+(1-t)b)-tf(a)+(1-t)f(b)]<0$. Take $s\in(0,1)$ to be the point where it is attained and let $x=sa+(1-s)b$. Then the linear function $L_x(ta+(1-t)b)-tf(a)+(1-t)f(b)$ has a strict local minimum at $t=s$, which is impossible. Step 2. We can replace the strict inequality in the conditions of Step 1 by a nonstrict one keeping the conclusion. Proof: Just subtract $\delta|x|^2$ with small $\delta>0$. Step 3: The distance to the boundary function satisfies the conditions of Step 1. Proof: Let $x\in G$. Let $y$ be the boundary point closest to $x$. Let $r$ and $S$ be the radius and the half-space for $y$. Then $L_x(z)=\text{dist}(z,\partial S)$ and $r$ work for $x$. Step 4: $G$ is convex. Proof: Take any 2 points $a,b$ in $G$. Suppose that the interval $[a,b]$ is not contained in $G$. Start moving $b$ towards $a$ along some path connecting them in $G$. Somewhere on the way, you'll get the situation when $a$ and $b$ are deep inside $G$ (that is true all the time) but $[a,b]$ is just barely inside $G$. Then the distance to the boundary dips on $[a,b]$, which is impossible due to the concavity just proved. The whole thing is certainly well-known and in good old times all of this would be written in most standard calculus textbooks (possibly, as an exercise). Unfortunately, nowadays we have to teach students to add fractions instead. Nevertheless, the textbooks in convex geometry and analysis written before 1980 would be your best bet if you want a reference. I would try something like Rockafellar's "Convex Analysis" to start with.