Digital Certificate & Hacienda Credentials

Before Astra can issue a single electronic document it needs four things from you: the .p12 cryptographic key, its PIN, and the username and password Hacienda assigned you. This guide covers the three things you ever do with them — upload them the first time, confirm they work, and replace them when the certificate expires. All of it happens on one screen.

The four items

All four come from Hacienda, but from two different places at two different moments. Mixing them up is the most common mistake when setting up a new organization.

Item What it is and where it comes from
Cryptographic key (.p12) The file every document is signed with. You generate and download it yourself from Hacienda's portal. Astra accepts a .p12 or .pfx file of up to 2 MB.
Certificate PIN The code that unlocks that file. You choose it when you generate the key, and Hacienda does not store it: lose it and the only way out is generating a new key. Older keys have a 4-digit PIN; keys generated in TRIBU-CR since July 2026 have at least 14 characters, with an uppercase letter, a lowercase letter, a number and a symbol. Astra accepts either, up to 64 characters.
Hacienda username The electronic-document user the tax authority assigns you. It looks like an email address — cpj-3-101-000000@prod.comprobanteselectronicos.go.cr. It is not the user you log into the portal with.
Hacienda password That user's password, also assigned by the tax authority.
The PIN is not the password

They are two different secrets and they are not interchangeable. The PIN unlocks the .p12 file; the Hacienda password authenticates the transmission against their servers. Astra checks them separately, so if one of them is wrong the verification panel tells you which.

All four are required

Three out of four issues nothing. While any of them is missing, the Hacienda send dialogs block the document and state exactly what is absent.

Where to set them

Open Settings at the bottom of the main sidebar → Electronic invoicing in Operations → Digital Certificate. On a phone, start at More → Organization Settings.

The Digital Certificate sub-tab for an organization with no certificate
A newly created organization: the yellow No certificate notice, and the verification panel still empty. The other three e-invoice sub-tabs — technical configuration, CABYS favorites and branches — play no part in this.

It is the same screen for everything: first upload, renewal and credential changes. There is no separate wizard and no other place to "update".

Uploading them for the first time

  1. Log into Hacienda's portal (TRIBU-CR) with your identification number and password.
  2. In the electronic documents section, generate the cryptographic key and set its PIN. Download the .p12 file and write the PIN down.
  3. If Hacienda assigns — or lets you change — the electronic-document username and password in that same step, write those down too: they are two of the four items.
  4. In Astra, open Organization Settings → Electronic Invoice → Digital Certificate.
  5. Under Cryptographic key (.p12), choose the file you downloaded.
  6. Type the PIN, the Hacienda username and the Hacienda password. Leave Expiry date and Key serial alone — those are not typed in.
  7. Press Save Changes and read the verification panel.
The certificate form with all four items loaded and both checks green
How the screen looks once all four items are in and verified. The PIN and the password are no longer shown: they become dots, with a Set badge next to the label.
The eye icon reveals what you are typing

The PIN and the password are masked as you type. The eye icon at the end of each field shows them in the clear — handy for checking a long value before saving.

What Astra fills in for you

Two fields on this screen are read-only and appear greyed out: Expiry date and Key serial. Astra reads both from the certificate itself when you save, and writes them for you.

  • They double as a sanity check: if the date that appears is not the one you expected, you uploaded the wrong file.
  • The expiry date is what drives the renewal alerts and the expired-certificate block.

Above them, the green Certificate configured card repeats both at a glance, with an Active badge.

The verification panel

Every time you save certificate changes, Astra runs two checks and writes the result into the Verification with the FE API panel.

Verification panel with both checks passing
The two lines are independent: the first opens the file with the PIN, the second authenticates the username and password against Hacienda. The date underneath is the last time this was checked, not the date of the last invoice.
  • Certificate and PIN — confirms the .p12 file opens with the PIN you saved.
  • Hacienda credentials (TRIBU-CR) — confirms the username and password authenticate.

The Verify now button re-runs both checks on demand, without saving anything. If Hacienda does not answer at that moment, the panel keeps the last result and a notice asks you to try again in a few minutes. It is the first thing to try when invoices stop going through and nobody changed anything: Hacienda credentials do expire and get revoked on their side.

What is saved when something fails

Before saving a new key, Astra checks it: if the PIN does not open it, it is a test key, it belongs to another ID number, it has expired, it is not valid yet, or the Hacienda username is not a production one or not yours, nothing is saved, the error appears above the field and your previous details stay as they were.

If the key passes that check, Astra checks the key, PIN, username and password with Hacienda before saving. If Hacienda rejects any of them, nothing is saved either and the error appears in red above the relevant field: the key if the problem is the file, the PIN, the expiry or the ID number; the password if Hacienda rejected the username or password. Fix the item named and save again.

If Hacienda does not answer, nothing is saved: wait a few minutes and save again. If you leave the PIN or password blank, or do not upload a new file, the check uses the ones already saved.

Renewing or replacing the certificate

Certificates expire. Renewing is exactly the same job as the first upload, on the same screen: generate the new key in Hacienda's portal, upload it, save. The new file replaces the old one rather than being added alongside it.

  1. Generate the new cryptographic key in Hacienda's portal and download the .p12.
  2. On Digital Certificate, choose the new file under Cryptographic key (.p12).
  3. Type the new PIN. If the PIN did not change, leave the field empty.
  4. If the electronic-document username or password changed at renewal, update them too. If they did not, leave them alone.
  5. Save, then confirm that Expiry date already shows the new date and that the verification panel is green.
An empty field means "leave it as it is"

The PIN and the password are never displayed back to you, so an empty field does not mean nothing is stored. On save, an empty field keeps the previous value; only what you type is changed. That lets you, for instance, update the Hacienda password without re-uploading the certificate.

Expiry alerts

You do not have to keep the date in a calendar. Astra watches it and emails a warning 30, 15, 7 and 1 day before expiry, to the organization's email address and to every user with the accountant role. The email carries the renewal steps.

An expired certificate issues nothing

No invoices, no tickets, no credit or debit notes. The send dialog blocks the document with the message "The organization's digital certificate has expired. You must upload a valid one." Renew when the first alert arrives, not on the last day.

Next to that block there is a button that emails the renewal instructions to the organization address and the accountants. It exists for the normal case: whoever hits the error at the point of sale is rarely the person with access to Hacienda's portal.

What else Hacienda requires

The certificate is half the requirement. Before letting a document out, Astra also checks the organization's identity, which is edited in Profile and contact on the same settings screen:

  • Identification number (personal or legal ID) and its type.
  • Economic activity code.
  • A name of at least 5 characters.
  • The organization's email address.

If any are missing, the send dialog lists them with a button that takes you straight to the field. Full organization setup is covered in Organization Settings, and the end-to-end issuing flow in Electronic Invoicing.

Who can do this

This screen is visible to the organization owner and to any user whose role carries the Electronic invoicing permission. It is deliberately separate from the general settings permission, so an external accountant can be given this and nothing else. Roles are edited under Organization Settings → Team.

The PIN and password are stored encrypted

They are never shown again, not even on the screen that received them — after saving they are only dots. Even so, treat the .p12 file and its PIN as what they are, your company's signature, and never send them by email or messaging app. Anyone holding both can sign electronic documents in your name.

Troubleshooting

What you see What happened
"The certificate could not be validated. Check the file and PIN, then try again." The file will not open with the PIN you typed. It is almost always the PIN, or a file that is not a certificate. Re-type the PIN with the eye icon on so you can read it, and confirm the file is the one you downloaded from your own portal. Nothing was saved.
"The certificate ID does not match Business identity…" The .p12 belongs to a different ID number. Download the production key for this business. Nothing was saved.
"This certificate has expired…" Generate a new key in your Hacienda portal and upload it with its PIN. Nothing was saved.
"This certificate is not valid yet: it starts on…" The key is new and only becomes valid on the date shown. Upload it from that day; until then the previous one stays in use. Nothing was saved.
"Hacienda credentials could not be verified. Check the production username and password…" The key is fine; the username or password is not. Remember the username is the electronic-document one — the one that looks like an email address — not your portal login. Nothing was saved.
"Hacienda is not responding right now…" Hacienda's servers did not answer, so nothing could be checked and nothing was saved. Try again in a few minutes. If you see "Too many verification attempts in a row", wait a minute.
"The settings were saved, but the FE API rejected the certificate or the PIN" Very rare: Hacienda accepted the details in the check, but sending them to the invoicing service failed afterwards. Press Verify now; if the error stays, save again.
The PIN will not save It accepts 4 to 64 characters: letters, numbers and symbols. If Astra says the PIN does not open the file, check it with the eye icon on: upper and lower case matter.
The file will not upload It must be a .p12 of 2 MB or less. Other extensions are rejected even when the contents are correct.
I saved and Expiry date is still empty Astra reads it while validating the certificate. If it did not fill in, validation did not pass — the verification panel has the reason.
Everything worked and now invoices bounce Press Verify now. If the second line turns red, the credentials changed on Hacienda's side; if it is the first, the certificate expired or was revoked.
I cannot see the Electronic Invoice tab Your role does not have the Electronic invoicing permission. Ask the organization owner for it.

Need more help?

Our team is ready to assist you.

EmailWhatsApp

Use Astra for your business

Astra · Astranexo

See plans and pricing