CM elliptic curves and primes captured by quadratic polynomials