
91 Cal.Rptr.2d 916 (2000)
77 Cal.App.4th 827
The PEOPLE, Plaintiff and Respondent,
v.
Michael Curtis YOUNG, Defendant and Appellant.
No. C030480.
Court of Appeal, Third District.
January 20, 2000.
Review Denied May 10, 2000.
*917 Sharon Fleming, under appointment by the Court of Appeal, for Defendant and Appellant.
Bill Lockyer, Attorney General, David P. Druliner, Chief Assistant Attorney General, Robert R. Anderson, Senior Assistant Attorney General, Stephen G. Herndon, Supervising Deputy Attorney General, Rachelle A. Newcomb, Deputy Attorney General, for Plaintiff and Respondent.
KOLKEY, J.
Following defendant's plea of no contest in exchange for a maximum sentence of 25 years to life, the trial court imposed the agreed maximum sentence, refusing to impose a lesser sentence by striking one or more of his prior conviction allegations. Defendant appealed, contending that the maximum sentence constitutes cruel and unusual punishment. We dismissed his appeal on account of his failure to obtain a certificate of probable cause pursuant to Penal Code section 1237.5,[1] but granted rehearing following defendant's request to brief the issue. We now reaffirm our earlier ruling and dismiss the appeal.
Under section 1237.5 and rule 31(d) of the California Rules of Court[2], no appeal may be taken by a defendant from a judgment of conviction upon a plea of guilty or nolo contendere except where a certificate of probable cause is filedunless the appeal deals with search and seizure issues, or is based on grounds "occurring after entry of the plea which do not challenge its validity." (Rule 31(d).)
In People v. Panizzon (1996) 13 Cal.4th 68, 79, 51 Cal.Rptr.2d 851, 913 P.2d 1061 (Panizzon), the California Supreme Court clarified that "a challenge to a negotiated sentence imposed as part of a plea bargain is properly viewed as a challenge to the validity of the plea itself and therefore requires that the defendant "seek and obtain a probable cause certificate in order to attack the sentence on appeal."
In this case, defendant's plea agreement did not provide for a particular sentence but for a maximum sentence, thereby allowing him to seek a lesser one. Nonetheless, we conclude that the defendant's challenge to the constitutionality of the maximum sentence that was part of his plea bargain is no less an attack on the validity of his plea. Accordingly, under the reasoning of Panizzon, supra, 13 Cal.4th at pp. 78-79, 51 Cal.Rptr.2d 851, 913 P.2d 1061, his appeal must be dismissed by virtue of his failure to obtain a certificate of probable cause.

I. FACTUAL AND PROCEDURAL BACKGROUND
Defendant pled no contest to transportation of cocaine (Health & Saf.Code, § 11352, subd. (a)), possession of cocaine (Health & Saf.Code, § 11350, subd. (a)), and possession of a firearm by a convicted felon (§ 12021, subd. (a)(1)).
Defendant also admitted that he had two robbery convictions (§ 211) and one conviction *918 for residential burglary (§ 459) within the meaning of section 1170.12, the Three Strikes law, and had served two prison terms within the meaning of section 667.5, subdivision (b).
In exchange for his pleas and admissions, defendant was promised a maximum sentence of 25 years to life in state prison and the opportunity to ask the trial court to strike one or more of his prior convictions. (See People v. Superior Court (Romero) (1996) 13 Cal.4th 497, 53 Cal. Rptr.2d 789, 917 P.2d 628.) At the time the defendant entered his no contest plea, the trial court made clear: "The ... maximum exposure ... [of] 25 to life ... is what the prosecution indicated should I not strike the prior convictions. They won't seek consecutive sentences. You are looking at 25 to life. [¶] But, you need to know the maximum punishment. If it went to trial and you were sentenced to the maximum exposure, it would be 52 years to life."[3]
At sentencing, the trial court declined to strike any of the prior conviction allegations, but imposed the agreed maximum term of 25 years to life. Defendant filed a notice of appeal, but did not obtain a certificate of probable cause pursuant to section 1237.5.
Defendant's sole contention on appeal is that the sentence constitutes cruel and unusual punishment.

II. DISCUSSION
Based on the reasoning of the California Supreme Court's decision in Panizzon, supra, 13 Cal.4th at pp. 74-79, 51 Cal.Rptr.2d 851, 913 P.2d 1061, we conclude that this appeal must be dismissed because the record contains no certificate of probable cause required pursuant to section 1237.5.
Section 1237.5 provides as follows: "No appeal shall be taken by the defendant from a judgment of conviction upon a plea of guilty or nolo contendere, or a revocation of probation following an admission of violation, except where both of the following are met: [¶] (a) The defendant has filed with the trial court a written statement, executed under oath or penalty of perjury showing reasonable constitutional, jurisdictional, or other grounds going to the legality of the proceedings, [¶] (b) The trial court has executed and filed a certificate of probable cause for such appeal with the county clerk."
However, "it is settled that two types of issues may be raised in a guilty or nolo contendere plea appeal without issuance of a certificate: (1) search and seizure issues for which an appeal is provided under section 1538.5, subdivision (m); and (2) issues regarding proceedings held subsequent to the plea for the purpose of determining the degree of the crime and the penalty to be imposed." (Panizzon, supra, 13 Cal.4th at p. 74, 51 Cal.Rptr.2d 851, 913 P.2d 1061.)
Rule 31(d) implements these exceptions by providing, inter alia, as follows: "If the appeal from a judgment of conviction entered upon a plea of guilty or nolo contendere is based solely upon grounds (1) occurring after entry of the plea which do not challenge its validity or (2) involving a search or seizure ... the provisions of section 1237.5 ... requiring a statement by the defendant and a certificate of probable cause by the trial court are inapplicable, but the appeal shall not be operative unless the notice of appeal states that it is based upon such grounds."
In Panizzon, supra, 13 Cal.4th at p. 79, 51 Cal.Rptr.2d 851, 913 P.2d 1061, our *919 state Supreme Court concluded that "a challenge to a negotiated sentence imposed as part of a plea bargain is properly viewed as a challenge to the validity of the plea itself and thus subject to compliance with section 1237.5. There, the defendant pleaded no contest to various felony counts, admitted a weapons use enhancement, and agreed to a sentence of life with the possibility of parole plus 12 years, in exchange for the dismissal of additional counts. After defendant was sentenced in conformity with the plea bargain, he filed a notice of appeal, claiming that his sentence was disproportionate to the sentences imposed upon his codefendants and thus violative of the federal and state constitutional prohibitions against cruel and unusual punishment. In rejecting defendant's contention that his appeal was based on a post-plea error (for which a probable cause certificate was not required) because he was claiming that the sentence was unconstitutional in comparison to the sentences imposed on his codefendants based on events that occurred after his no contest plea, the high court observed that "all the trial court did here was to sentence defendant in accordance with the previously entered plea." (13 Cal.4th at p. 78, 51 Cal. Rptr.2d 851, 913 P.2d 1061) It ruled: "[T]hat the events supposedly giving rise to defendant's disproportionality claim occurred afterwards ... is of no consequence. Rather, `the crucial issue is what the defendant is challenging.' [Citation] Here, by contesting the constitutionality of the very sentence he negotiated as part of the plea bargain, defendant is, in substance, attacking the validity of the plea. For that reason, ... we hold that the certificate requirement of section 1237.5 applies." (13 Cal.4th at p. 78, 51 Cal. Rptr.2d 851, 913 P.2d 1061.)
The high court explained the rationale underlying its ruling in Panizzon as follows:
"In determining whether section 1237.5 applies to a challenge of a sentence imposed after a plea of guilty or no contest, courts must look to the substance of the appeal: `the crucial issue is what the defendant is challenging, not the time or manner in which the challenge is made.' [Citation.] Hence, the critical inquiry is whether a challenge to the sentence is in substance a challenge to the validity of the plea, thus rendering the appeal subject to the requirements of section 1237.5." (13 Cal.4th at p. 76, 51 Cal.Rptr.2d 851, 913 P.2d 1061, emphasis in original.)
Likewise, the defendant in this case is attacking the validity of his plea. The prosecution agreed to a maximum sentence of 25 years to life in return for defendant's plea. Yet, defendant now attacks that maximum sentence on the ground that it is cruel and unusual punishment. By arguing that the maximum sentence is unconstitutional, he is arguing that part of his plea bargain is illegal and is thus attacking the validity of the plea. Having failed to obtain a certificate of probable cause, defendant cannot appeal. (See also, People v. Sabados (1984) 160 Cal.App.3d 691, 695-696, 206 Cal.Rptr. 799 [where defendant pleaded guilty to first degree murder with the knowledge that his sentence would be 25 years to life, his claim that the sentence was disproportionate could not be considered on appeal absent a certificate of probable cause because "his challenge is to the validity of his plea to first degree murder"].)
Defendant argues that Panizzon does not apply because he "did not agree to a particular negotiated sentence" as did the Panizzon defendant.
Admittedly, the defendant in Panizzon challenged the constitutionality of the sentence to which he agreed, whereas defendant here challenges the constitutionality of the maximum sentence to which he agreed. Nonetheless, by attacking the maximum term, defendant seeks to void a term of the agreement to which both parties agreed to abide (see People v. Walker (1991) 54 Cal.3d 1013, 1024, 1 Cal.Rptr.2d 902, 819 P.2d 861), and is "in substance, attacking the validity of the plea." (Panizzon, *920 supra, 13 Cal.4th at p. 78, 51 Cal. Rptr.2d 851, 913 P.2d 1061.)
We are mindful that "[t]he purpose for requiring a certificate of probable cause is to discourage and weed out frivolous or vexatious appeals challenging convictions following guilty and nolo contendere pleas." (Panizzon, supra, 13 Cal.4th at p. 75, 51 Cal.Rptr.2d 851, 913 P.2d 1061; accord, People v. Breckenridge (1992) 5 Cal.App.4th 1096, 1101, 8 Cal.Rptr.2d 1.) Accordingly, section 1237.5 requires a showing of reasonable grounds to challenge the validity of that which was agreed before an appeal can be pursued. Defendant's attack on the legality of his maximum sentence is an effort to unilaterally improve, and thus alter, the terms of that which was agreed and thus should not be permitted without a certificate of probable cause. To allow the defendant to challenge a term in his plea agreement without obtaining a certificate of probable cause would defeat the purpose of the statute and undermine the benefitscertainty and economythat a plea agreement is intended to achieve.
Defendant also argues that dismissal of his appeal is contrary to the California Supreme Court's decision in People v. Lloyd (1998) 17 Cal.4th 658, 72 Cal.Rptr.2d 224, 951 P.2d 1191. Citing Lloyd, he contends that where a defendant asserts error arising from the trial court's determination of the penalty to be imposed following a plea, the validity of that plea is not challenged. However, in People v. Lloyd, supra, 17 Cal.4th 658, 72 Cal.Rptr.2d 224, 951 P.2d 1191, the defendant had entered a plea of nolo contendere "without a plea bargain." (17 Cal.4th at p. 661, 72 Cal. Rptr.2d 224, 951 P.2d 1191.) On appeal, the defendant claimed that the trial court erred in concluding that it did not have discretion to vacate any of the findings of his prior convictions. Our Supreme Court held that the Court of Appeal erred in dismissing the appeal for failure to obtain a certificate of probable cause, explaining that the grounds of his appeal occurred after entry of his plea and did not challenge the validity of his plea. (17 Cal.4th at p. 665, 72 Cal.Rptr.2d 224, 951 P.2d 1191.) The high court distinguished Panizzon: "In Panizzon, we recognized that, even if it purportedly challenges the sentence only, a defendant's appeal from a judgment of conviction entered on a plea of guilty or nolo contendere must be dismissed in the absence of a statement of grounds by the defendant and a certificate of probable cause by the trial court if, in substance, it challenges the validity of the plea. [Citation.] It does so if the sentence was part of a plea bargain. [Citation] It does not if it was not [citation] especially so if the claim or claims in question were `reserved as part of the plea agreement' [citation]." (17 Cal.4th at p. 665, 72 Cal.Rptr.2d 224, 951 P.2d 1191.)
In this case, unlike Lloyd and like Panizzon, the defendant's challenge to his sentence, even if based on post-plea events, was an attack on a term of the plea agreement. (And in Panizzon, even though the defendant claimed that the purported disproportionality of his sentence was based on post-plea events, the Supreme Court noted that his sentence was part of his plea agreement.)
Finally, defendant contends that "by reserving the right to challenge the imposition of a 25 years to life term, [defendant] obviously reserved the right to challenge such a sentence on any appealable grounds, including cruel and unusual punishment grounds." However, the defendant did not reserve his right to challenge the constitutionality of the maximum sentence. He merely reserved the opportunity to ask the trial court to exercise its discretion to strike one or more of the prior conviction allegations. Even if he could have challenged without a certificate of probable cause the trial court's exercise of its discretion whether to strike his prior convictions on the ground that it was a matter that "occurr[ed] after entry of the plea which do[es] not challenge its validity" (rule 31(d))an issue we do not address *921 a challenge to the maximum sentence to which defendant agreed as part of his plea bargain does challenge the validity of the plea because it challenges one of its material terms.
Accordingly, we conclude that defendant may not challenge the constitutionality of the maximum sentence that was agreed as part of his plea bargain in the absence of a certificate of probable cause.

DISPOSITION
The appeal is dismissed.
BLEASE, Acting P.J., and RAYE, J., concur.
NOTES
[1]  Unless otherwise designated, all further statutory references are to the Penal Code.
[2]  Unless otherwise designated, all further references to rules are to the California Rules of Court.
[3]  Such a prison term assumes consecutive sentences for two of the counts. Defendant contends that "it is not at all apparent that consecutive terms would have been mandatory in this case because arguably the offenses were all committed on the same occasion." However, assuming without deciding that his contention is correct, that does not mean that the court could not have imposed consecutive sentences in its discretion. (See People v. Deloza (1998) 18 Cal.4th 585, 595-596, 76 Cal.Rptr.2d 255, 957 P.2d 945.)
