
205 Cal.App.2d 394 (1962)
ED H. RIMINGTON, Cross-complainant and Appellant,
v.
GENERAL ACCIDENT GROUP OF INSURANCE COMPANIES et al., Cross-defendants and Respondents.
Civ. No. 10241. 
California Court of Appeals. Third Dist.  
July 2, 1962.
 Bert W. Levit, John B. Hook and Long & Levit for Cross-complainant and Appellant.
 Honey, Mayall, Hurley & Knutsen, Edwin Mayall, George H. Hauerken, Cyril Viadro and Hauerken, St. Clair, Zapettini & Hines for Cross- defendants and Respondents. *395
 PEEK, P. J.
 Defendant Ed Rimington appeals from an order striking his cross-complaint for declaratory relief, which order also sustained cross-defendants' demurrer to the cross-complaint without leave to amend.
 Plaintiff Stockton Husk Company filed a complaint by which it sought a determination of the rights and liabilities of Rimington, General Accident Group of Insurance Companies, Birmingham Fire Insurance Company, the American Insurance Company, and others not concerned in this appeal. The complaint charged that Rimington, the alleged agent of the named defendants, orally agreed to insure plaintiff's corn husk crop in the amount of $41,000 against loss or destruction by fire for a premium to be computed later by Rimington and billed to plaintiff; that the amount of the policy was to be allocated among the defendant companies; that the following day the corn husk crop was totally destroyed by fire; that plaintiff notified defendants of the loss; that each of the defendants denied liability, contending that no policy of insurance was then in existence; and that by reason of the foregoing, a controversy existed. The complaint concluded with the prayer that the rights and obligations of the parties and the extent thereof be declared.
 The answer of Birmingham and American denied that Rimington was an authorized agent for them, and for that reason there was no binding agreement of insurance with plaintiff. General admitted an agency agreement with Rimington, but denied that Rimington intended or purported to act on its behalf in regard to insuring plaintiff's corn husk crop. A like allegation was made in Rimington's answer.
 Subsequently, Rimington filed a cross-complaint against defendants Birmingham, American, and General, wherein he sought a judgment declaring the rights and liabilities of cross-defendants; that if the court determined that any sum was due plaintiff, the court should determine that the liability is that of cross-defendants; that he was entitled to be indemnified by cross- defendants in the amount of any judgment that might be rendered against him; and that he was entitled to damages for loss of reputation and damage to his insurance business, together with costs and attorney's fees.
 Cross-defendants, Birmingham jointly with American and General concurrently, moved to strike the cross-complaint on the ground that it was "premature, inappropriate, unnecessary and mere surplusage in the present action." *396
 The three grounds urged by cross-defendants in their memoranda of points and authorities in support of their demurrers and motions to strike were that the cross-complaint failed to state facts sufficient to constitute a cause of action against cross-defendants; that the cross-complaint was premature in that the right to sue for indemnity could arise only when payment had been made by the indemnitee and that, in any event, declaratory relief was improper since there was no actual controversy between the parties.
 The trial court, without comment, granted the motions to strike and sustained the demurrers without leave to amend.
 On appeal, cross-defendants, relying on Weissman v. Lakewood Water & Power Co., 173 Cal.App.2d 652 [343 P.2d 776], contend that the question before the trial court was essentially one of discretion. They further point out that several of the issues raised by the cross-complaint are collateral to the issues of the main case and would necessarily involve considerable evidence entirely different from that to be introduced in the action between plaintiff and defendants, and that the trial court, pursuant to section 1061 of the Code of Civil Procedure, is free to exercise its discretion and refuse declaratory relief where the declaration is not necessary or proper at the time under all the circumstances.
 After cross-defendants filed their briefs on appeal, the Supreme Court in Roylance v. Doelger, 57 Cal.2d 255 [19 Cal.Rptr. 7, 368 P.2d 535], held that the proper procedure for the trial court is to permit the filing of a cross-complaint under circumstances falling within the language of section 442 of the Code of Civil Procedure, subject, however, to the right of the trial court to determine, under the provisions of section 1048 of the Code of Civil Procedure, whether the issues tendered by the complaint and the answer thereto shall be tried together with those raised by the cross-complaint, or be severed.
 The pertinent portions of section 442 of the Code of Civil Procedure, as amended in 1957, provide: "Whenever the defendant seeks affirmative relief against any person, whether or not a party to the original action, relating to or depending upon the contract, transaction, matter, happening, or accident upon which the action is brought or affecting the property to which the action relates, he may, in addition to his answer, file at the same time ... a cross-complaint."
 Here the transaction to which the cross-complaint relates is *397 the very one upon which plaintiff Stockton Husk Company has founded its action; that is, an alleged contract of insurance with defendant insurance companies that was negotiated through their alleged agent, Rimington, and a denial of liability by defendants. Thus, the primary question raised by plaintiff's complaint would be whether there was a contract of insurance with any one or all defendants; and if so, then who were the negotiating and contracting parties. Thus the evidence in regard to the making of the alleged contract and the liability of the several defendants would be the same under the cross-complaint as under the complaint and answer.
 The trial court's order striking the cross-complaint and sustaining the demurrer is general in its terms and does not indicate the grounds upon which the court acted. However, the other grounds advanced by cross-defendants, in support of their motion to strike and their demurrers, are that the cross- complaint does not sufficiently state a cause of action and that the right to sue for indemnity accrues only after payment has been made by the indemnitee.
 We find no merit in these contentions. [1] A complaint for declaratory relief is legally sufficient if it sets forth facts showing the existence of an actual controversy relating to the legal rights and liabilities of the respective parties and requests that these rights and liabilities be adjudged by the court. (Maguire v. Hibernia S. & L. Soc., 23 Cal.2d 719 [146 P.2d 673, 151 A.L.R. 1062].)
 [2] As a general rule, an agent pursuing the instructions of his principal and acting within the scope of his authority who then becomes personally liable for the performance of the contract made for his principal, can look to the principal for indemnity for the damage sustained. (Rest. 2d Agency,  438, 439, pp. 322-334; 2 Am.Jur., Agency,  294, pp. 231- 232.)
 [3] The allegations here leave no doubt of the asserted existence of an actual controversy between the parties. The issue of possible indemnification would be a justiciable controversy involving the insurance companies and their alleged agent, concerning the legal relations and rights arising out of the transaction of the main action.
 Furthermore, inasmuch as Rimington is seeking declaratory relief it is immaterial that no judgment has been rendered. [4] The purpose of a declaratory judgment is to settle actual controversies before they have ripened into a violation of a contractual obligation. (1 Anderson, Declaratory Judgments *398 (2d ed.)  137, p. 253.) Under section 1060 of the Code of Civil Procedure, "Such declaration may be had before there has been any breach of the obligation in respect to which said declaration is sought." (See also Sattinger v. Newbauer, 123 Cal.App.2d 365 [266 P.2d 586]; Simon Hardware Co. v. Pacific Tire, etc., Co. [Harcourt v. Simon Hardware Co.] 199 Cal.App.2d 616 [19 Cal.Rptr. 12].)
 The order is reversed.
 Schottky, J., and Pierce, J., concurred.
