Yes, your solution is also correct, and many times when we find differing forms for an indefinite integral, we find that they (without the constant of integration) differ only by a constant, which of course is allowed.
So, let's look at the two solutions without the constants:
(1) $$\frac{1}{2}\cos^2(x)-\ln|\cos(x)|$$
(2) $$\ln|\sec(x)|-\frac{1}{2}\sin^2(x)$$
First, we should observe that:
$$\ln|\sec(x)|=\ln|(\cos(x))^{-1}|=-\ln|\cos(x)|$$
So, if we subtract one solution from the other, we should obtain a constant. Subtracting (2) from (1), we get:
$$\frac{1}{2}\cos^2(x)+\frac{1}{2}\sin^2(x)$$
Using a Pythagorean identity, we now have:
$$\frac{1}{2}$$
So, we see that the two solutions differ by a constant, which means they are equivalent as an anti-derivative.
Perhaps a simpler way to look at it is to take the solution you obtained, and rewrite it:
$$\ln|\sec(x)|-\frac{1}{2}\sin^2(x)+C=-\ln|\cos(x)|-\frac{1}{2}\left(1-\cos^2(x) \right)+C=\frac{1}{2}\cos^2(x)-\ln|\cos(x)|+\left(C-\frac{1}{2} \right)$$
Since an arbitrary constant less one half, is still an arbitrary constant, we get:
$$\frac{1}{2}\cos^2(x)-\ln|\cos(x)|+C$$