We are interested in equilibrium properties of confined electrolytes surrounded by charged solid walls. The problem is formulated in terms of the electrostatic potential and the ionic concentrations of the constituants which have prescribed spatial mean values. In a first part, we will present our main result which asserts the existence and uniqueness of the saddle point of the free energy functional and its characterization as a solution of a system of conservation equations. Numerical illustrations of this setting based on finite elements discretization and a Newton-Raphson algorithm are presented. In a second part, we will discuss several mathematical and numerical aspects of the case where the free-energy functional is no longer a convex functional of the concentrations. This case is particularly relevant for divalent and trivalent ions. For this physical setting, phase separation between diluted and condensed phase can occur for high surface charge density.