For what it's worth, there are a number of good quality, reliable 10mm pistols that can be carried concealed (Glock, Sig Sauer). As other folks have mentioned, the onus is on you to determine applicable state laws when carrying a firearm for protection. Bear spray is typically the best compromise, but of course has drawbacks as well (single use, accidental discharge, wind, etc). Pistols are also heavy when it comes to thru-hiking, and don't have the same weather/dirt resistance as a can of bear spray.