Here's a derivation my textbook gives for the variance of the return $R_p$ of a portfolio of stocks with arbitrary weights $x_i$:
$$ \mathrm{Var}(R_p) = \mathrm{Cov}\left( R_p, \sum_{i=1}^n x_iR_i \right) = \sum_{i=1}^n x_i \mathrm{Cov}(R_p, R_i) = \sum_{i=1}^n x_i \cdot \rho_{p,i} \cdot \sigma_p \cdot \sigma_i $$
What justifies the first equals sign here?
Presumably $R_p = \sum_{i=1}^n x_i R_i$. You can check from definitions that $\text{Var}(R_p) = \text{Cov}(R_p, R_p)$.