Pepper spray, aka bear spray, is legal to carry in California, but is limited to 2.5 oz containers and is for self-defense situations only.
"In California, pepper spray is legal when used in self-defense situations, but must be carried in 2.5 oz or smaller containers. Because pepper spray has a variety of self-defense uses, California residents are permitted to carry it in these smaller containers. In a state with densely populated cities like Los Angeles and San Francisco, pepper spray can be a useful tool for self-defense against human attackers and has prevented muggings, rapes, and other attacks. California also touts beautiful forests, natural landmarks, and vast wide-open spaces, so pepper spray can also be useful to hikers and outdoorsmen who may encounter mountain lions, bears, wild animals, dogs, and other potentially dangerous animals."
Also, I noticed the California Department of Fish and Game has a link directly from their website on where you can buy Bear Pepper Spray.
BUT the rules for National Parks appears to override the state regulations:
"The possession, use, or discharge of pepper spray (including bear spray), pellet guns, and BB guns in Yosemite National Park is prohibited."