If I know the masses of the two bodies (they have equal mass), how do I calculate the two ellipse eccentricities, length of the apoapsis and speed at the apoapsis, that make stable system, as in this picture.
You can't. There are an infinite number of stable orbits that are possible depending on the angular momentum and total energy of the system - which must be negative for a bound orbit.
If you specify the eccentricity (there is only one eccentricity value for the orbit) and orbital period then Kepler's third law will give you the semi-major axis, from which, the apoapsis can be calculated. Or if you specify the apoapsis then the eccentricity can be calculated. If you wish to consider the centre of mass frame then each body executes an ellipse with the same eccentricity (see here for example) and with equal semi-major axes (if the masses are equal), where their sum is equal to the semi-major axis of the system.
The speed at apoapsis can be obtained from the vis viva equation once the orbital parameters are established.