[§ 41] Mistake of Fact Distinguished From Mistake of Law.
It is necessary to keep in mind the difficult distinction between excusable mistake of fact and inexcusable ignorance of law (supra, §36). Thus, in People v. Flanagan (1924) 65 C.A. 268, 223 P. 1014, defendant was convicted of criminal syndicalism, based upon proof that he had joined the I.W.W. and that this organization advocated the prohibited acts of sabotage, etc. Defendant testified that he had been told it was a "labor organization." But the trial judge refused to permit him to answer his counsel's question whether he understood that the purposes of the organization were to be carried out by force and violence. Held, this was error; defendant could not be punished for agreeing to further a purpose of which he was unaware. In other words, (1) if defendant had known that the organization advocated force and violence, and had believed this activity to be legal, his excuse would be ignorance of the law, and untenable; (2) but a mistaken belief that the organization had no such purposes gave him the good defense of mistake of fact.
In People v. Flumerfelt (1939) 35 C.A.2d 495, 96 P.2d 190, it was held that defendant was entitled to show that her attorney had informed her that a permit to sell stock had been issued. Advice of the attorney that a permit was unnecessary would not have been a defense (mistake of law, supra, §38); but reliance in good faith on information from the attorney might be (mistake of fact, supra, §39).
In People v. McLaughlin (1952) 111 C.A.2d 781, 245 P.2d 1076, supra, §36, the court, rejecting the defense of mistake of law, pointed out that if the defendants had been ignorant of the illegal activities of the users of their service, i.e., ignorant of the purpose to be served, their defense would have been good. (111 C.A.2d 789.)
People v. Costa (1991) 1 C.A.4th 1201, 2 C.R.2d 720, involved both mistake of fact andmistake of law. Defendant, charged with manufacturing amphetamine in violation of Health & Saf. C. 11379.6 (2 Cal. Crim. Law (3d), Crimes Against Public Peace and Welfare, §112), claimed that he believed-mistakenly--that the person he aided to set up a narcotics laboratory was a police informant and hence immune from prosecution. Even if the facts had been as defendant believed them to be, his actions would still have been illegal; his belief that an informant's immunity under Health & Saf.C. 11367 (infra, §245) would extend to him was an inexcusable mistake of law.(1 C.A.4th 1211, 1212.)
SUPPLEMENT:
See People v. Young (2001) 92 C.A.4th 229, 233, 111 C.R.2d 726 [defendant's erroneous belief Compassionate Use Act of 1996 permitted him to transport marijuana as medicine was inexcusable mistake of law, not mistake of fact].

Witkin & Epstein California Criminal Law, Third Edition
Copyright (c) 2002 by West Group
ALBA WITKIN, executor
of the estate of BERNARD E. WITKIN

CHAPTER III - DEFENSES

II. OTHER CONDITIONS AFFECTING INTENT
B. Mistake of Law.
1. In General.

1 WitkinCal. Crim. Law Defenses § 37

[§ 37] In General.
The distinction sometimes stated between inexcusable ignorance of law and excusable mistake of law has little substance. It is simply an easy way of describing the exceptional situations in which ignorance of the actual law--or mistaken belief that the law is something other than it is--may be considered as a defense. (See Perkins 3d, p. 1028.) Normally the mistake will be a belief in some legal right to do the act under a law or legal doctrine distinct from the criminal statute that is being violated. (See Perkins 3d, p. 1031.) In any case, however, the defendant's mistaken belief must be honest, although it need not necessarily be reasonable. (See Perkins 3d, p. 1035.)
One situation is fairly clear: if the crime requires specific intent,mistake of law may negative that intent. Thus, in a bona fide dispute between seller and buyer over a title, lien, or right to possession of personal property, the unwarranted taking of the goods by the buyer under a misconception of the buyer's legal rights will not constitute larceny. The intent to steal, an essential ingredient of the offense, is wholly lacking. ( People v. Photo (1941) 45 C.A.2d 345, 353, 114 P.2d 71; see People v. Eastman (1888) 77 C. 171, 19 P. 266;People v. Bernhardt (1963) 222 C.A.2d 567, 592, 35 C.R. 401, citing the text; People v. Gard (1978) 76 C.A.3d 998, 1004, 143 C.R. 346 [defendant physician thought his drug possession was legal; jury was adequately instructed on this valid defense and rejected it]; 66 Cal. L. Rev. 809; 4 Cal. Crim. Forms & Instructions (2d), §49:4 [mistake of law as negating specific intent]; 21 Am.Jur.2d (1998 ed.), Criminal Law §153; 1 Wharton, Crim. Law (15th ed.), §79.)
The same is true where other special mental states, such as malice or corruption, are required. (See People v. Goodin (1902) 136 C. 455, 458, 69 P. 85;1 Cal. Crim. Law (3d), Elements, §§10, 11.)
To constitute a good defense, the mistake must be one that negatives the intent or other mental state that is an element of the crime. In People v. Smith (1966) 63 C.2d 779, 48C.R. 382, 409 P.2d 222, defendant's counsel asked him whether, when he entered a place to cash forged checks, he had "any knowledge" that this "would constitute a crime of burglary in California." Held, the specific intent to commit burglary is simply the felonious design with which the accused enters--here to commit larceny. "In short, the law recognizes honest purpose, not dishonest ignorance of the law, as a defense to a charge of committing a crime requiring 'specific intent.' " (63 C.2d 793.)
SUPPLEMENT:
See People v. Ramsey (2000) 79 C.A.4th 621, 631, 94 C.R.2d 301 [mistake of law was no defense in prosecution for discharging pollutants into river (Water C. 13387) because statute does not expressly indicate that knowledge that discharged material is pollutant is element of offense].

II. OTHER CONDITIONS AFFECTING INTENT
B. Mistake of Law.
2. Reliance on Advice, Statute, or Regulation.

1 WitkinCal. Crim. Law Defenses § 38

[§ 38] Reliance on Advice, Statute, or Regulation.
(1) Reliance on Advice of Counsel. The defense of action taken in good faith, in reliance upon the advice of a reputable attorney that it was lawful, has long been rejected. The theory is that this would place the advice of counsel above the law and would place a premium on counsel's ignorance or indifference to the law. (See People v. Vineberg (1981) 125 C.A.3d 127, 137, 177 C.R. 819 [reliance on attorney's advice that Department of Corporations letter authorized defendants' activities was wholly unreasonable; instruction on that theory was properly refused]; People v. Flora (1991) 228 C.A.3d 662, 670, 279 C.R. 17, citing the text; People v. Honig (1996) 48 C.A.4th 289, 347, 348, 55 C.R.2d 555, 2 Cal. Crim. Law (3d), Crimes Against Governmental Authority, §105, quoting the text; 21 Am.Jur.2d (1998 ed.), Criminal Law §156; 1 Wharton, Crim. Law (15th ed.), §42.)
(2) Reliance on Advice of Administrative Officer. Where regulatory statutes are enforced by an administrative agency, good faith reliance on the advice or ruling of the agency may be considered an excuse. This view was taken in People v. Ferguson (1933) 134 C.A. 41, 24 P.2d 965, where defendant issued securities on the advice of the California Corporations Commissioner that no permit was required. The court held that he was entitled to offer this fact in evidence: "[W]e cannot believe the law so inexorable as to require the brand of felon upon him for following the advice obtained. The mere statement of the facts demonstrates that such strict construction would be unconscionable and more calculated to engulf the innocent law-abiding business man than to punish the guilty or to protect the security buyer. By the very attitude of the corporation commissioner's office ... appellant was forced to sell the securities in question without a permit or not to sell them at all. Such a state of affairs is not imaginable, for, as we have seen, the sale of such securities is not malum in se." (134 C.A. 53.) (See People v. Bray (1975) 52 C.A.3d 494, 496, 499, 124 C.R. 913, infra, §50 [possession of firearm by felon; state regulatory agencies had indicated that defendant was not a felon].)
Other cases have reached a different result. (See People v. Settles (1938) 29 C.A.2d Supp. 781, 785, 78 P.2d 274 [distinguishing Ferguson case; no defense that lottery violating state law was viewed as game of skill by local police commission]; People v. Sapse (1980) 104 C.A.3d Supp. 1, 13, 163 C.R. 920 [fact that defendant was told by investigator for Board of Medical Examiners that he could use prefix "Dr." informally among friends and family, but not when advising or consulting with others, did not estop state from prosecuting him for misrepresenting himself as medical doctor to investigator posing as prospective patient's relative 6 years later].)
(3) Reliance on Statute, Administrative Regulation, or Court Decision. On principle it would seem that action taken in good faith and in reliance on an apparently valid statute or administrative regulation (which turns out to be void) is no basis for a criminal conviction. (See 14 Cal. Western L. Rev. 48; 21 Am.Jur.2d (1998 ed.), Criminal Law §154.) And reliance on a court decision upholding the validity of a statute or interpreting its terms should likewise be a defense. (See 22 Cal. L. Rev. 570; 1 Wharton, Crim. Law (15th ed.), §79; 21 Am.Jur.2d (1998 ed.), Criminal Law §155.)
The defense of good faith reliance on an administrative regulation may be established by a special statute. (See, e.g., Fin.C. 5204(b) [violation of Savings Association Law, 2 Cal. Crim. Law (3d), Crimes Against Public Peace and Welfare, §§327, 328].)