The claim does not hold. A counterexample is given by $n=14$, $p=134123250258009499$ and correspondingly $$N = 2197475332227227631617 = 193 \cdot 12289 \cdot 926510094425921.$$ It can be easily verified that $$3^{(N-1)/2} \equiv 1 \pmod{N},$$ but $N$ is not prime. --- A couple more values of $N$ giving counterexamples: $$300334937065845770469377,\ 80203520301265852381167617.$$ **ADDED.** Here is a list of [659 of counterexamples](https://gist.github.com/maxale/b09e4ac7889dccb1706db9bff17dbc3b) that I found.