Previous studies have shown that extrasolar Earth-like planets in close-in habitable zones around M-stars are weakly protected against galactic cosmic rays (GCRs), leading to a strongly increased particle flux to the top of the planetary atmosphere. Two main effects were held responsible for the weak shielding of such an exoplanet: (a) For a close-in planet, the planetary magnetic moment is strongly reduced by tidal locking. Therefore, such a close-in extrasolar planet is not protected by an extended magnetosphere. (b) The small orbital distance of the planet exposes it to a much denser stellar wind than that prevailing at larger orbital distances. This dense stellar wind leads to additional compression of the magnetosphere, which can further reduce the shielding efficiency against GCRs. In this work, we analyse and compare the effect of (a) and (b), showing that the stellar wind variation with orbital distance has little influence on the cosmic ray shielding. Instead, the weak shielding of M star planets can be attributed to their small magnetic moment. We further analyse how the planetary mass and composition influence the planetary magnetic moment, and thus modify the cosmic ray shielding efficiency. We show that more massive planets are not necessarily better protected against galactic cosmic rays, but that the planetary bulk composition can play an important role.