Germany and Canada have signed an agreement to boost cooperation in critical raw materials including rare earths as Berlin tries to reduce its dependence on Chinese imports.